Linux under Vim in the tab set to 4 blank examples

Source: Internet
Author: User


Using 4-Space tab in most files, a true 8-width tab is used in Makefile, and colleagues are automatically indented based on the type of file.

Edit

Vim ~/.VIMRC

If the file does not exist new, the file already exists, append to the tail

Add to

"This part of the code is executed only when Autocommands is supported."
If has ("Autocmd")
"Use file type checking and file-based automatic tightening
FileType plugin indent on

"tab use length 8 in the makefiles file."
Autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab
endif

"For other cases, use 4-space-width tab
The width of the Set tabstop=4 tab is set to 4 spaces.
"But still is \ t." Just vim interprets it as 4 spaces wide, with another editor or \ t symbol
"Vim would interpret it to being
"A width of 4."
Set shiftwidth=4 the width of 4 spaces.
Set Softtabstop=4 sets the number of columns that tab occupies, set to the width of 4 spaces when you enter tab.
Set Expandtab "Extended tab is a space.
Vim temporarily turns off indent and annotation auto indent settings

Vim automatically indents the code, makes the code a mess, and maybe even because a comment on a line causes all of the subsequent code to be commented out,

Method One

Set Pastetoggle

You can turn off automatic indentation

or set as a shortcut key, the most convenient way is to add a sentence in the. VIMRC:

Set pastetoggle=<f9>

Later in the Insert mode, you can toggle the automatic indentation by pressing the F9 key.

When you need your own handwriting code, enter insert mode, the default is automatically indented.

Method Two

Set paste
Then go into insert mode and paste, the code will not be automatically indented.
When you need to automatically indent the code, you need to change it back:

Set Nopaste

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.