Linux system configuration VI or VIM tips

  
                  

1, VI or VIM configuration file path


The discovery /usr/share/vim/vimrc and /etc/vim/vimrc point to the same file, ie vimrc, vi and Vim configuration file, modify this file. This path may vary in different LINUX versions.


2, configuration color


With the color display of Xuan VI and VIM, it can highlight some special words, which is very useful for writing programs. Later, I opened the file and found that there is already a line in it. I just commented it out with quotation marks. Just remove the quotation marks in front of the line where the syntax on is located. Or add a separate line: syntax on also, and edit /etc/profile to add a line of alias vi="vim".


3. Set the mouse


When editing the text using the VI, if you want to repair the file from a position farther away from the cursor, you want to use the mouse to locate, you can default In this case, the mouse is not available. If you want to use the mouse, just take another line and write: set mouse=a to


4, set auto-indentation


By default, VI And VIM are not indented, each time you change a line, the cursor is positioned in the top grid, if you want to automatically align, please remove the quotation marks in front of the line where set autoindent, or add another line: set autoindent. This is similar to configuring colors. The result of this setting is that the new line is automatically aligned with the previous line after pressing Enter.


5, set the amount of tab indentation


If you write programs in python, then line indentation is an extremely important concept, the indentation of the same block The amount must be the same. You might like to add a space before the line to indicate indentation, but you must type the space bar multiple times. If you like to use the TAB key to indicate indentation, you may find that the text or program you write is not very good, because the default Under, VI and VIM have a large TAB indentation (at least six or seven characters). Set the TAB key indentation: set shiftwidth=3 You can also choose an indentation you like, such as 2, or 4

Copyright © Windows knowledge All Rights Reserved