Using vi in ubuntu is a solution for changing the direction keys to garbled characters _ The backspace key cannot be used. This evening, the teacher assigned us a ubuntu Virtual Machine and said we would like to use it for experiments. Of course, it doesn't matter. My favorite is ubuntu, but it may be a very difficult experiment process for some people who are not familiar with linux.
The teacher asked us to edit some files in ubuntu, which involved the vi editor. In ubuntu, when vi is initially used, it is a problem that when the direction key is used in editing mode, it does not move the cursor, however, if [A [B [C [D and other letters are displayed in the command line and the editing is incorrect, the Backspace key cannot be used at ordinary times, delete can only be used. There are many answers to this question on the Internet, such as installing the full version of vim and editing/etc/vim/vimrc. tiny and other methods are messy. Here I will make a detailed summary: www.2cto.com
1. edit/etc/vim/vimrc. tiny because the owner of/etc/vim/vimrc. tiny is a root user, you must modify the file with the root permission. The penultimate sentence in this file is "set compatible", as shown below:
Change "compatible" to "nocompatible" to incompatible mode to solve the problem of changing the direction key to ABCD. Next, we need to solve the problem of Backspace keys. In the previous sentence, we will add the following sentence: [cpp] set backspace = 2, as shown in the following figure:
You can solve the problem. At this time, no matter which user, vi can easily edit files according to our habits. Www.2cto.com II. Install vim full version Because ubuntu is pre-installed with tiny version, it will cause the above inconvenience in use. However, after the vim full version is installed, all the keys on the keyboard are normal under vi.
First, uninstall the earlier version of vi and enter the following command:
[Cpp] sudo apt-get remove vim-common and install vim in full. Run the following command: [cpp] sudo apt-get install vim.
After the installation, we still use the "vi" command to start the newly installed vim when editing the file, but the operation is more convenient than tiny.
3. Adding a ". vimrc" file is not a clever method. It is edited in the user's personal directory. vimrc file (note that the file name is ". "), add the following two statements: [cpp] set nocompatible // set backspace = 2 in incompatible mode, as shown in: www.2cto.com
After saving and exiting, you can use vi to avoid invalid keyboard direction keys and Backspace keys.
It is not a clever method because we have to add ". in order to make all users use the vi function normally, this is a relatively large workload. Therefore, it is not recommended, although I initially used this solution (because there are only two users in my system, which is relatively small ). There is always one of the above three methods that suits you. It's better to select the best one !! Prepared by AI_Net