Set vi tab indent in environment variables

Source: Internet
Author: User

The TAB key on the terminal is indented 8 spaces by default (remember that 8 spaces are not equal to a tab, tab, and space are not a concept)

This is usually the case when the tab (tab) indent of Vim is set: Set tabstop=4 "means that the tab width is displayed as the width of the 4 spaces
After setting up you don't think a tab is equal to 4 spaces, they are not equal, when is it equal? Set Expandtab "means tab (tab) becomes a space
After setting up, a 4-space-length tab is equal to 4 spaces.

Attach the settings in vim for auto indent (auto indent required for general line breaks):
Set autoindent "Turn on auto indent
set shiftwidth=4"   Auto indent 4 spaces
Set softtabstop=4 "Shiftwidth and TabStop not the same, you will find the program is rather ugly."

At this time, the softtabstop is in effect;
For example, if set softtabstop=8, then press TAB, insert a normal tab, if set softtabstop=16, then insert is two tabs; if softtabstop=12, Then insert a tab character plus 4 spaces;
What if softtabstop=4? At first, the insertion is 4 spaces, and once you press the tab again, this time the four spaces will be combined with the last four spaces into a tab. In other words, Softtabstop is "every 8 spaces into 1 tabs", if you tabstop=8
Here is my vim about indentation configuration: "tab width set tabstop=4set expandtab" Unified indent to 4set Softtabstop=4set shifwidth=4

Indentation is always tab in VI, but some tabs are indented 4 and some are indented 8. How to set it up in the environment?

method One, add Export exinit= "set Showmode tabstop=4" in ~/.BASHRC
method Two, touch ~/.EXRC file. Write set tabstop=4 in the inside

If not, try source ~/.BASHRC

Set vi tab indent in environment variables

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.