Vim code format settings

Source: Internet
Author: User

When you use vim to edit the vim code format in a terminal, by default, the editing interface does not display line numbers, syntax high brightness, smart indentation, and other functions. To better work in vim, You need to manually set a configuration file:. vimrc. When vim is started. the vimrc file is automatically read, which can contain some settings or even scripts. it is easier to create a vimrc file in the root directory of the current user, that is, to create a command: $ vi ~ /. After vimrc is set, save $: x or $ wq and exit. The following is an example that lists frequently used settings. For detailed settings, see reference: "behavior comment lines starting with double quotation marks, the same below:" Remove annoying vi consistency patterns, avoid bugs and limitations in earlier versions: set nocompatible "show row number" check file type filetype on "set history = 1000" the background uses Black set background = dark" syntax on "The following two lines of code are being written, it is useful in the format pair. "In the first line, vim uses automatic start, that is, applies the format of the current row to the next line." In the second line, based on the preceding start-up format, you can intelligently select the start-up mode. for C-language programming, "set autoindentset smartindent" is useful in writing. The tab key is set to four spaces in the first line, the second row sets four spaces when the rows are staggered. set tabstop = 4 set shiftwidth = 4 "sets the matching mode, Similarly, when you enter a left brace, the corresponding right brace set showmatch will be matched. "Remove toolbarset guioptions = T in the vim GUI version." If the command is incorrect when vim is edited, this setting removes the set vb t_vb = "set ruler" in the lower right corner of the editing process. By default, search for matching is highlighted. It is very convenient to turn off the highlighted set nohls. For example, to search for the book word, when/B is entered, the first word starting with B is automatically found. When/bo is input, the word starting with B is automatically found, using this setting will quickly find the answer. When you find the matching word ", do not forget to press set incsearch" to modify a file and then perform automatic backup, add "~" to the original file name "Suffix if has (" vms ") // note that double quotation marks must be enclosed in half-width quotation marks" "set nobackupelseset backupendif. if annotations are removed, a complete one is provided. vimrc configuration information is as follows: set nocompatibleset numberfiletype on set history = 1000 set background = dark syntax on set multicast tabstop = 4 set Keys = 4 set showmatchset guioptions-= Tset vb t_vb = set rulerset nohlsset incsearchif has (" vms ") set nobackupelseset backupendif

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.