Home Operation and Maintenance Linux Operation and Maintenance How to solve the problem that linux vi does not display the cursor

How to solve the problem that linux vi does not display the cursor

May 30, 2023 pm 10:34 PM
linux vi

linux vi不显示光标的解决办法:1、登录linux系统,进入终端;2、通过执行“echo -e "\033[?25h"”方法显示光标即可。

Linux终端光标消失问题

今天在用vim写脚本的时候,突然间发现光标消失了,这就很难受了,不知道编辑位置在哪。

一开始一直在找vim的配置问题,但是后来发现终端的光标也消失了。

这才知道终端的光标和vim的光标是关联的,所以只需要把终端的光标搞出来就行了。

隐藏光标

echo -e "\033[?25l"
Copy after login

显示光标

echo -e "\033[?25h"
Copy after login

相关拓展:

在Linux终端中,你可以快速移动光标、进行命令编辑、执行编辑中的历史命令、使用Bang(!)命令和控制命令。让basher更有效率。

一、说明

Ctrl – k: 先按住 Ctrl 键,然后再按 k 键;

Alt – k: 先按住 Alt 键,然后再按 k 键;

M – k:先单击 Esc 键,然后再按 k 键。

二、移动光标

Ctrl – a :移到行首

Ctrl – e :移到行尾

Ctrl – b :往回(左)移动一个字符

Ctrl – f :往后(右)移动一个字符

Alt – b :往回(左)移动一个单词

Alt – f :往后(右)移动一个单词

Ctrl – xx :在命令行尾和光标之间移动

M-b :往回(左)移动一个单词

M-f :往后(右)移动一个单词

三、编辑命令

Ctrl – h :删除光标左方位置的字符

Ctrl – d :删除光标右方位置的字符(注意:当前命令行没有任何字符时,会注销系统或结束终端)

Ctrl – w :由光标位置开始,往左删除单词。往行首删

Alt – d :由光标位置开始,往右删除单词。往行尾删

M – d :由光标位置开始,删除单词,直到该单词结束。

Ctrl – k :由光标所在位置开始,删除右方所有的字符,直到该行结束。

Ctrl – u :由光标所在位置开始,删除左方所有的字符,直到该行开始。

Ctrl – y :粘贴之前删除的内容到光标后。

Alt + t :交换光标处和之前两个字符的位置。

Alt + . :使用上一条命令的最后一个参数。

Ctrl – _ :回复之前的状态。撤销操作。

Ctrl -a + Ctrl -k 或 Ctrl -e + Ctrl -u 或 Ctrl -k + Ctrl -u 组合可删除整行。

四、Bang(!)命令

!! :执行上一条命令。

foobar :把上一条命令里的foo替换为bar,并执行。

!wget :执行最近的以wget开头的命令。

!wget:p :仅打印最近的以wget开头的命令,不执行。

!$ :上一条命令的最后一个参数, 与 Alt - . 和 $_ 相同。

!* :上一条命令的所有参数

!*:p :打印上一条命令是所有参数,也即 !*的内容。

^abc :删除上一条命令中的abc。

foobar :将上一条命令中的 foo 替换为 bar

foobar^ :将上一条命令中的 foo 替换为 bar

!-n :执行前n条命令,执行上一条命令: !-1, 执行前5条命令的格式是: !-5

五、查找历史命令

Ctrl – p :显示当前命令的上一条历史命令

Ctrl – n :显示当前命令的下一条历史命令

Ctrl – r :搜索历史命令,随着输入会显示历史命令中的一条匹配命令,Enter键执行匹配命令;ESC键在命令行显示而不执行匹配命令。

Ctrl – g :从历史搜索模式(Ctrl – r)退出。

六、控制命令

Ctrl – l :清除屏幕,然后,在最上面重新显示目前光标所在的这一行的内容。

Ctrl – o :执行当前命令,并选择上一条命令。

Ctrl – s :阻止屏幕输出

Ctrl – q :允许屏幕输出

Ctrl – c :终止命令

Ctrl – z :挂起命令

七、重复执行操作动作

M – 操作次数 操作动作 : 指定操作次数,重复执行指定的操作。

The above is the detailed content of How to solve the problem that linux vi does not display the cursor. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to start nginx in Linux How to start nginx in Linux Apr 14, 2025 pm 12:51 PM

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

How to check whether nginx is started How to check whether nginx is started Apr 14, 2025 pm 01:03 PM

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to start nginx server How to start nginx server Apr 14, 2025 pm 12:27 PM

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

How to solve nginx304 error How to solve nginx304 error Apr 14, 2025 pm 12:45 PM

Answer to the question: 304 Not Modified error indicates that the browser has cached the latest resource version of the client request. Solution: 1. Clear the browser cache; 2. Disable the browser cache; 3. Configure Nginx to allow client cache; 4. Check file permissions; 5. Check file hash; 6. Disable CDN or reverse proxy cache; 7. Restart Nginx.

How to check whether nginx is started? How to check whether nginx is started? Apr 14, 2025 pm 12:48 PM

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

How to solve nginx403 error How to solve nginx403 error Apr 14, 2025 pm 12:54 PM

The server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.

How to clean nginx error log How to clean nginx error log Apr 14, 2025 pm 12:21 PM

The error log is located in /var/log/nginx (Linux) or /usr/local/var/log/nginx (macOS). Use the command line to clean up the steps: 1. Back up the original log; 2. Create an empty file as a new log; 3. Restart the Nginx service. Automatic cleaning can also be used with third-party tools such as logrotate or configured.

Difference between centos and ubuntu Difference between centos and ubuntu Apr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

See all articles