Shiftwidth, tabstop, and softtabstop settings of VIM

Source: Internet
Author: User

1 shiftwidth

This is usedProgramIndicates the white space length used for automatic indent. In general, to keep the program beautiful, it is best to be consistent with the following parameters. It is also the setter of the symbol shift length.

2 tabstop

It is recommended to set the length of spaces equivalent to the tab value to 8, because if it is another value, it may make the file look awkward in printing and other fields. Unless you have setExpandtabMode, that is, to convert tabs into spaces, so that it will not be confused. However, after all, 8 is the most common setting, so do not change it.

3 softtabstop

what if we want to change the indentation in the program? shiftwidth and tabstop not the same, you will find the program ugly. At this time, softtabstop it takes effect. You can see from the description in VIM that once the softtabstop value is set, press the tab key, insert a mix of spaces and Tab tabs. The actual mixing depends on the configured softtabstop . For example, if softtabstop is set to 8, press the tab key to insert a normal tab. If softtabstop is set to 16, two tabs are inserted. If softtabstop is set to 12, A tab is inserted with four spaces. What if softtabstop = 4? At the beginning, there are four spaces inserted. Once you press the tab again, the four spaces will be combined with the previous four spaces to become a tab. In other words, softtabstop is "every 8 spaces into 1 tab ", the premise is that you tabstop = 8 .

4 about expandtab

For example, when multiple developers develop projects togetherCodeThe style should be as consistent as possible. Generally, the Tab character is not allowed in the code, but four spaces are used instead. You can edit an object that contains the following content:
Set shiftwidth = 4
Set expandtab

Then add the following command to. vimrc:
Autocmd filetype C, CPP set shiftwidth = 4 | set expandtab

You can implement this setting only when editing the C and CPP files.

(Original address:
Http://blog.csdn.net/ludonghai715/archive/2010/06/09/5657712.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.