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.