autoindent is subset of smartindent in vim?

柔情痞子 提交于 2020-01-11 18:49:32

问题


:help autoindent : Copy indent from current line when starting a new line (typing in Insert mode or when using the "o" or "O" command). ...

:help smartindent : Do smart autoindenting when starting a new line. Works for C-like programs, but can also be used for other languages. ...

Normally 'autoindent' should also be on when using 'smartindent'. 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 '{'. ...

smartindent also coping indent from current line when starting a new line. That means autoindent feature is subset of smartindent feature and no need of autoindent if smartindent is on, right? Why autoindent should be turn on?


回答1:


smartindent is an old script that was meant, when it was written, to be a "smart" complement to autoindent. Since then, most languages have either specific indentation functions or use cindent with specific options.

Generally, smartindent shouldn't be used at all.

The following lines are usually enough to deal with indentation:

set autoindent
filetype plugin indent on

autoindent is not strictly necessary but it's good to have it when working with plaintext.



来源:https://stackoverflow.com/questions/18415492/autoindent-is-subset-of-smartindent-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!