Vim Configuration and usage

Source: Internet
Author: User

The Vim configuration file path is typically/ETC/VIM/VIMRC


CTRL + P//prompt to be padded

GG=G//Automatic typesetting

$//Move the cursor to the end of the bank.

: X//Save exit

:%s/emacs/vim/g//Replace all Emacs in the current line with VIM

The number of indented cells after set Shiftwidth//gg=g

Set HLS//settings match highlighting

Set nohls//Suppress highlighting


Automatically return to the last edited place when you open the file:

If has ("Autocmd")
Autocmd bufread *.txt Set tw=78
Autocmd Bufreadpost *
\ If line ("' \" ") > 0 && line (" ' \ "") <= Line ("$") |
\ exe "normal g ' \" "|
\ endif
endif


CD-//linux back to the previous Open Directory command

1. Location of configuration files
Under directory/etc/, there is a file named VIMRC, which is a public vim configuration file in the system and is valid for all users. In each user's home directory, you can create a private configuration file, named: ". VIMRC". For example, under the/root directory, a. vimrc file is usually already present.
2. Set syntax highlighting
1) Open VIMRC and add the following statement to make syntax highlighting:
Syntax on
2) If the syntax is not highlighted at this point, then add the following statement in the profile file in the/etc directory:
Export Term=xterm-color

3. Set the Windows-style C + + Auto Indent (add the following set statement to VIMRC)
1) Set (soft) tab width to 4:
Set tabstop=4
Set softtabstop=4
2) Set the number of spaces in the indent to 4
Set shiftwidth=4
3) Set auto indent: The indent value of each line is equal to the previous line; Use Noautoindent to cancel the setting:
Set Autoindent
4) Set the automatic indentation using the C + + language:
Set Cindent
5) To set the specific indentation for the C + + language (in my Windows style example):
Set Cinoptions={0,1s,t0,n-2,p2s, (03s,=.5s,>1s,=1s,:1s
6) If you want to display the line number of the text on the left, you can use the following statement:
Set Nu
7) Finally, if you do not have the following statement, add it:
If &term== "Xterm"
Set T_co=8
Set T_SB=^[[4%DM
Set T_SF=^[[3%DM
endif



The setup of Vim is only for Ubuntu and Fedora Systems, and I have not experimented with other Linux versions, so please understand this. Thank you

The configuration file for vim in Ubuntu is stored in the/etc/vim directory with the configuration file named VIMRC

The configuration file for vim in Fedora is stored in the/etc directory with the configuration file named VIMRC

Enter the following command at the terminal to edit the VIMRC configuration file: (You can also use SHIFT +: Enter the corresponding command during the edit file)
sudo vim/etc/vim/vimrc
or sudo gedit/etc/vim/vimrc

1, display line number

Add a new line at the end of the file, enter set Nu

2. Syntax highlighting
In the file, find "syntax on this line, remove the preceding double quotes", double quotation marks are the meaning of the comment

3. Auto Indent

Add a line at the end of the file, enter set Autoindent
On the Add line, enter set Cindent
Where autoindent is automatically indented; Cindent is automatically indented for C language syntax

Note: If you set the above settings, VIM does not make the corresponding action, then please upgrade your vim to the latest version, generally as long as the terminal input the following command: sudo apt-get install vim

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.