Ubuntu vi command garbled solution

Ubuntu vi command garbled solution

Release Time:2022-02-07 19:05:15

When using vi under ubuntu, the arrow keys are garbled and the backspace key cannot be used.

 

Problem performance: Under Ubuntu, when vi is used initially, and the arrow keys are used in editing mode, the cursor will not move, but letters such as ABCD appear in the command line, and if the editing is wrong, even the backspace key is created ( backspace) cannot be used and can only be deleted with delete.

 

Solution:

 

First use sudo apt-get install vim

 

1. Edit /etc/vim/vimrc.tiny

 

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

ubuntu vi命令乱码

Modifying compatible to nocompatible non-compatible mode can solve the problem that the arrow keys change to ABCD. Next, solve the problem that the backspace key cannot be used. Add the sentence set backspace=2 after the previous sentence as follows:

ubuntu vi命令乱码

 

At this time, the problem has been solved, no matter which user, using vi can easily edit the file according to our habits.

 

2. Install vim full version

 

Since the tiny version is pre-installed in ubuntu, it will cause the above inconvenience when we use it, but after we install the full version of vim, the keys on the keyboard are normal under vi.

 

Solution:

Uninstall tiny version sudo apt-get remove vim-common

Install the full version sudo apt-get install vim