Set Tab to 4 spaces in Vim

Source: Internet
Author: User



Indentation tab or space, this is not a problem, just like python with four spaces to indent, this is to see a person's preferences. In Vim, it is convenient to set the Tab tab or space according to different file types, and also to set the length, which is very flexible.



First, let's see how to set the tab width and how to determine whether to use Tab tab or empty Glyd to represent an indentation:


set tabstop=4set softtabstop=4set shiftwidth=4set noexpandtab/expandtab


Description:




softtabstopIndicates the length of the indent when pressing the backspace bar while in edit mode, when using theexpandtabis particularly useful.

shiftwidthIndicates the length of each level indent, typically set tosofttabstopThe same.

When set toexpandtab, the indentation is denoted by an empty Glyd,noexpandtabis a tab representation of an indentation.


To set tab according to file type:



Sometimes you want to set different tab performance for certain types of files, such as Python with four empty glyd for an indentation, and four null glyd for indentation in our JavaScript conventions, and HTML and CSS like tab tabs to indent, so you can do the following:

ifHas ("Autocmd") autocmd FileType JavaScript setlocal ts=4sts=4sw=4Expandtab autocmd FileType python setlocal ts=4sts=4sw=4Expandtabendif


So when the file is  .js. PY  will be indented with four spaces.



To represent tab tabs with special symbols:



In Vim, you can use special symbols to represent a tab tab so that tab tabs and spaces can easily be distinguished, such as:









To join in VIMRC:


set list  set listchars=tab:?\, EOL:?


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.



Set Tab to 4 spaces in Vim


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.