Vim tab skills

Source: Internet
Author: User

The vim tab technique is used to modify the actual code. Various alignment problems may occur when the generated diff files are browsed on different tools. It looks ugly. Therefore. in vimrc, the "set expandtab" option is specified to replace the tab directly with tabstop or the four bytes specified by shiftwidth. Once specified, in some cases, it will not adapt. For example, the command statement in makefile specifies to start with the table key, otherwise he does not know it. So there are the following: 1. set the position of the tab: set tabstop = 42. when you enter a tab, it is automatically converted to a space: set expandtab. If you need to enter a real tab, enter Ctrl + V, tab, and Ctrl + Q in Windows, tab (either in ubuntu or in lower case v) or directly ": set noexpandtab" Reset 3. convert existing tabs into spaces: retab the rules used for conversion are currently tested based on the value of "tabstop, that is, a tab key is converted to "tablstop" Space 4. set the width of the tab in editing mode: set softtabstop does not change tabstop, but makes the tab appear to be the specified width during editing. When you enter the tab, the tab is inserted with a mix of spaces, for example? Tabstop = 4, softtabstop = 10. When you insert a tab, the cursor is moved for 10 characters. It may be two tabs with two spaces (alignment occurs in reality, so it is possible, but not necessarily), which is also effective for backspace. 5. solve the trouble when shiftwidth and tabstop are different: set smarttab inserts a blank space with the shiftwidth width when entering the tab at the beginning of the line, and processes 6 by tabstop and softtabstop elsewhere. show tab as visible character: set list listchars = tab:>-tab will be displayed as> -- format 7. add the following code to the tab only when editing a specific type of file ~ /. Vimrcautocmd FileType * set tabstop = 4 | set shiftwidth = 4 | set noexpandtabautocmd FileType python set tabstop = 4 | set shiftwidth = 4 | set expandtab The FileType can be recognized by c, cpp, make, ruby, and python. Other tests are not currently available. If you are not sure, you must test it on your own.

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.