Using vi under ubuntu is a solution that the arrow keys become garbled and the backspace key cannot be used

 

In insert mode, there is no response to pressing the delete key. Press the arrow keys to print out A, B, C, and D respectively, one line for each character.

 

1. Edit /etc/vim/vimrc.tiny

Since the owner of /etc/vim/vimrc.tiny is the root user, this file needs to be modified under root authority. Very simple, the penultimate sentence in this file is "set compatible", as follows:   

                                       

 

Change the "compatible" to "nocompatible" non-compatible mode to solve the problem of the arrow keys changing to ABCD. Next, it is very simple to solve the problem of the Backspace key. Add a sentence after the sentence just now:

 

set backspace=2 becomes as shown below:

                                       

 

It will solve the problem. At this time, no matter which user, using vi can easily edit files according to our habits.

2. Install vim full version

Since ubuntu is pre-installed with a tiny version, it will cause the above inconvenience in our use. However, after we installed the full version of vim, all the keys of the keyboard are normal under vi.

First, to uninstall the old version of vi, enter the following command:

sudo apt-get remove vim-common Then install the full version of vim, enter the command: sudo apt-get install vim After this is installed, we still use the "vi" command to start the newly installed vim when editing files, but It is more convenient to operate than tiny.

3. Add ".vimrc" file

This is not a smart approach. It is in the user's personal directory, edit the .vimrc file (note that the file name starts with "."), and add the following two sentences:

 

set nocompatible //Work in non-compatible mode set backspace=2 as shown below:

                                         

 

After saving and exiting, the user can use vi in ​​the future to avoid the problem that the keyboard arrow keys and Backspace keys are invalid.

The reason why it is not a smart way is because we have to add a ".vimrc" file to each user's personal directory so that all users can use vi's functions normally, which is a relatively large workload. So it is not recommended, although I initially used this method to solve it (because there are only 2 users on my system, which is relatively small).

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327055552&siteId=291194637