[Linux] Perfect solution to the inability to use the arrow keys and backspace key in vi under ubuntu18.04

Insert image description here

I just installed ubuntu18.04 today and found that when using the vi command to configure the file, I found that using the arrow keys could not move the cursor, but a bunch of strange English letters appeared, and the backspace key could not delete the content normally. I am used to CentOS. I already feel that Ubuntu is not as smooth as CentOS, but there is no way. Ubuntu is the mainstream in my subsequent experimental study. I summarized the above problems and came up with the following two solutions:

Article directory

1.Method 1:

I checked online and found that this is because Ubuntu comes pre-installed with vim-tiny, and we need to use vim-full. Execute the following statement to install the full version of vim.

This problem is caused by the fact that the new system is pre-installed with vi instead of vim. Because vi does not support directly using the backspace key to delete characters, deleting characters with the backspace key can only take effect when the esc key is pressed. In contrast, vim can edit characters directly like Notepad, which is more convenient

Just execute the following two commands in sequence to perfectly solve the problem of the vi editor arrow keys changing to letters under Ubuntu. That is: uninstall the current vi editor and then reinstall it.

First open a command line window and log in as the root administrator.

1. Execute the command

sudo apt-get remove vim-common

2. Execute the command

sudo apt-get install vim

Try the vi editor again and you can see that the arrow keys and backspace key can be used normally.

1.Method 2:

Since the owner of /etc/vim/vimrc.tiny is the root user, this file must be modified with root permissions.

su root

Use the command vi /etc/vim/vimrc.tiny under the root user to modify the file and set set compatible to set nocompatible incompatible mode. This will solve the problem of the direction keys changing to ABCD.

vi /etc/vim/vimrc.tiny

This is because sometimes the system defaults to vim being compatible with vi, so vi commands are used.

The next step to solve the problem of the Backspace key is also very simple. Just add another sentence after the sentence just now: set backspace=2.

Insert image description here

set nocompatible
set backspace=2

The above are the two methods to solve the problem that the direction keys and backspace key cannot be used in vi under ubuntu18.04. Friends and seniors are welcome to provide valuable opinions. If this article is helpful to you, please like, collect and follow~

Guess you like

Origin blog.csdn.net/beixige/article/details/133435324