Vim tab settings

Source: Internet
Author: User

From Vim manual:

 

Option:
1. tabstop: the number of spaces displayed for a tab. The default value is 8.
2. softtabstop: the number of spaces in a tab during editing (for example, press the return or tab key... I didn't fully understand)
3. expandtab/noexpandtab: Expand or not expand the tab into spaces.
4. shiftwidth: the number of spaces for each level of indentation
5. smarttab: determines the number of spaces in a tab based on the number of indentation spaces in other parts of the file.

 

Command:
: [Range] retab [new_tabstop]: Apply the new tabstop value and replace all tabs. If expandtab is set, all tabs in the file are replaced with spaces.

 

Common usage:

 

1. Retain the tab. Keep tabstop by default, set softtabstop and shiftwidth to 4, and set noexpandtab. In this way, if there is a tab in the file, it will be retained, and the new indent will also use the tab.

 

2. Use spaces for all. Set tabstop and shiftwidth to the same value, for example, 4, and set expandtab. In this way, spaces are used for the new indent. Press the tab key and all spaces are displayed. If there is a tab in the file, you can use the retab command again to extend all tabs into spaces, which is perfect.

 

I usually set it in. vimrc as follows:

Set smarttab <br/> set tabstop = 4 <br/> set shiftwidth = 4 <br/> set expandtab

Related logs:

Vim tab settings (2): Use autocmd to apply different tab settings for different file types: http://blog.csdn.net/shell_picker/archive/2010/12/13/6073125.aspx

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.