我该如何制作vi-Vim永远不要使用制表符(将空格转换为制表符,不好!),使制表符键 == 4 个空格,并在大括号块后自动缩进代码,例如Emacs does?
另外,如何保存这些设置,这样我就不必再次输入它们?
我见过与此相关的其他问题,但它似乎总是与我想要的有点偏离。
正如其他几个答案中所指出的,现在首选的方法不是使用 smartindent,而是使用以下内容(在您的.vimrc):
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
In your [.vimrc:][1] file:
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
帮助文件需要一些时间来适应,但是你读得越多,Vim 就越好:
:help smartindent
更好的是,您可以将这些设置嵌入到源中以实现可移植性:
:help auto-setting
要查看您当前的设置:
:set all
As graywh在评论中指出,smartindent 已被 cindent 取代,它“工作得更巧妙”,尽管仍然主要用于具有类似 C 语法的语言:
:help C-indenting
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)