vim中的縮排

來源:互聯網
上載者:User

標籤:des   style   os   io   for   ar   art   sp   line   

縮排 縮排的設定
  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 except or CTRL-D and then type
, CTRL-O or , the indent is deleted again.

簡單來講就是產生的新行的縮排值與上一行保持一致。

  1. 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了:對編程中{}的相關縮排做了較好的支援。

  1. cindent (ci)

Enables automatic C program indenting.

對C程式適配的自動縮排。並且與“cinkeys”、“cinwords”、“cinoptions”配合產生效果。

  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 ‘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的縮排設定哦~

  1. 這幾種縮排設定之間的關係

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

  1. paste
    當開啟了以上的那些xxindent之後,從其他視窗粘貼到vim時會因為縮排出現格式的錯亂,為了避免這種現象,可以通過開啟paste選項使得各種indent失效,保持原文的縮排。完成之後再將其關閉。當paste選項開啟時,當切換到插入模式時,下方的狀態列會有提示:insert (paste)

vim中的縮排

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.