autoindent 是 vim 中 smartindent 的子集吗? [英] autoindent is subset of smartindent in vim?

查看:25
本文介绍了autoindent 是 vim 中 smartindent 的子集吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:help autoindent :开始新行时从当前行复制缩进(键入在插入模式或使用o"或O"命令时)....

: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 :开始新行时进行智能自动缩进.适用于 C 类程序,但也可用于其他语言....

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

通常在使用smartindent"时也应该打开autoindent".自动插入缩进:

  • 在以{"结尾的行之后.
  • 在以 'cinwords' 中的关键字开头的一行之后.
  • 在以 '}' 开头的行之前(仅适用于O"命令).

  • 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 还可以在开始新行时从当前行缩进.这意味着 autoindent 功能是 smartindent 功能的子集,如果 smartindent 开启,则不需要 autoindent,对吗?为什么应该打开 autoindent?

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?

推荐答案

smartindent 是一个古老的脚本,在编写时旨在成为 autoindent 的智能"补充.从那时起,大多数语言要么具有特定的缩进功能,要么使用带有特定选项的 cindent.

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.

一般来说,根本不应该使用smartindent.

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 不是绝对必要的,但在处理纯文本时使用它是很好的.

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

这篇关于autoindent 是 vim 中 smartindent 的子集吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆