Vim Multiple lines Increase Indent

Source: Internet
Author: User

http://blog.163.com/[email protected]/blog/static/11135225920116891750734/

Under normal mode, the command >> increments the current line, and the command decreases the << indentation for the current line. We can use numbers before the command to specify the scope of the command's function. For example, the following command will reduce the indentation of 5 lines:

5<<

Under Insert/replace mode,Ctrl-Shift-t可以增加当前行的缩进,而Ctrl-Shift-d则可以减少当前行的缩进。使用0-Ctrl-Shift-d命令,将移除所有缩进。需要注意的是,当我们输入命令中的“0”时,Vim会认为我们要在文本中插入一个0,并在屏幕上显示输入的“0”;然后当我们执行命令0-Ctrl-Shift-d时,Vim就会意识到我们要做的是减少缩进,这时0会就会从屏幕上消失。

The indent width defaults to 8 spaces. We can modify the indentation width by using the following command:

:set shiftwidth=4

Use the following settings, each time you clickTab键,将增加宽度为8列的Tab缩进。

:set tabstop=8

:set softtabstop=8

:set shiftwidth=8

:set noexpandtab

Use the following settings, each time you clickTab键,增加的缩进将被转化为4个空格。

:set tabstop=4

:set softtabstop=4

:set shiftwidth=4

:set expandtab

Where theexpandtab option is used to control whether tab is converted to a space. However, this option does not change the text that already exists, and if you need to apply this setting to convert all tabs to spaces, you need to execute the following command:

:retab!

Auto Indent

In Vim can also be automatic indentation, mainly cindent, smartindent and autoindent three kinds.

cindent Vim can well identify structured programming languages such as C and Java, and can be used to process the indentation structure of a program using the C language indentation format. You can enable the Cindent indent structure by using the following command:

:set cindent

smartindent In this indentation mode, each row has the same indentation as the previous line, and the indentation form correctly identifies the curly brace, and when the right curly brace (}) is encountered, the indentation is canceled. In addition, the ability to identify C keyword is added. If a line starts with #, this format will be treated in a special way instead of indented format. You can enable the Smartindent indent structure by using the following command:

:set smartindent

autoindent In this form of indentation, the newly added row and the previous line use the same indentation form. You can use the following command to enable the Autoindent indent form.

:set autoindent

Command Summary
>> Increase Indent
Ctrl-Shift-t
<< Reduce indentation
Ctrl-Shift-d
:set shiftwidth=n Set Indent width
:set cindent Enable Cindent indent structure
:set autoindent Enable Autoindent indent structure
:set smartindent Enable Smartindent indent structure

http://yyq123.blogspot.com/2010/10/vim-indent.html

Vim Multiple lines Increase Indent

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.