標籤:des style os io for ar art sp line
縮排 縮排的設定
- 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 except or CTRL-D and then type
, CTRL-O or , the indent is deleted again.
簡單來講就是產生的新行的縮排值與上一行保持一致。
- smartindent (si)
An indent is automatically inserted:
- After a line ending in ‘{‘.
- After a line starting with a keyword from ‘cinwords‘.
- 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 ‘{‘.
在autoindent的基礎上更加smart了:對編程中{}的相關縮排做了較好的支援。
- cindent (ci)
Enables automatic C program indenting.
對C程式適配的自動縮排。並且與“cinkeys”、“cinwords”、“cinoptions”配合產生效果。
- 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 ‘indentkeys‘ 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.
更加個人化的指定縮排的設定。還可以用Lisp的縮排設定哦~
- 這幾種縮排設定之間的關係
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 configurable to different indenting styles.
‘indentexpr‘ 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|.
- paste
當開啟了以上的那些xxindent之後,從其他視窗粘貼到vim時會因為縮排出現格式的錯亂,為了避免這種現象,可以通過開啟paste選項使得各種indent失效,保持原文的縮排。完成之後再將其關閉。當paste選項開啟時,當切換到插入模式時,下方的狀態列會有提示:insert (paste)
vim中的縮排