Indent in VIM

Source: Internet
Author: User
Indent settings
  1. Autoindent (AI)

Copy indent from current line when starting a new line (typing
In insert mode or when using the "O" or "O" Command). If you do not
Type anything on the new line before T or CTRL-D and then type
CTRL-O or, the indent is deleted again.

Simply put, the indent value of the new line is consistent with that of the previous line.

  1. Smartindent (SI)

An indent is automatically inserted:

  • After a line ending in '{'.
  • After a line starting with a keyword from 'cinword '.
  • Before a line starting with '}' (only with the "O" command ).
    When typing '}' as the first character in a new line, that line is
    Given the same indent as the matching '{'.

Based on autoindent, it is more smart: it provides better support for the indentation of {} in programming.

  1. Cindent (CI)

Enables automatic C program indenting.

Auto indent for C program adaptation. It works with "cinkeys", "cinwords", and "cinoptions" to produce results.

  1. Indentexpr (INDE)

Expression which is evaluated to obtain the proper indent for a line.
It is used when a new line is created, for the |=| operator and
In insert mode as specified with the 'initkeys 'option.
When this option is not empty, it overrules the 'cindent 'and
'Smartindent 'indenting. When 'lisp 'is set, this option is
Overridden by the lisp indentation algorithm.

More personalized settings for specific indentation. You can also use the indentation settings of lisp ~

  1. Relationship between the indentation settings

There are in fact four main methods available for indentation, each one
Overrides the previous if it is enabled, or non-empty for 'indentexpr ':
'Autoindent 'uses the indent from the previous line.
'Smartindent 'is like 'autoindent' but also recognizes some C syntax to increase/reduce the indent where appropriate.
'Cindent 'works more cleverly than the other two and is retriable to different indenting styles.
The most flexible of all: Evaluates an expression to compute the indent of a line. When non-empty this method overrides the other ones. See | indent-expression |.

  1. Paste
    After the above xxindent is enabled, the indentation format will be disordered when pasting from other windows to VIM. To avoid this phenomenon, you can enable the paste option to invalidate various indent, retain the indent of the original text. Close it after completion. When the paste option is enabled and the insert mode is switched, the following status bar will prompt: insert (paste)

Indent 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.