本文介绍了Tab键== 4个空格,在Vim中花括号后自动缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何制作 vi - Vim 从不使用制表符(将空格转换为制表符,很糟糕!),使制表符== 4个空格,并在卷曲后自动缩进代码像 Emacs 这样的支撑块?

How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does?

此外,如何保存这些设置,这样我就不必再次输入它们了?

Also, how do I save these settings so I never have to input them again?

我还看到了与此有关的其他问题,但它似乎总是与我想要的东西有些偏离.

I've seen other questions related to this, but it always seems to be a little off from what I want.

推荐答案

正如以下几个答案所指出的那样,现在首选的方法是不使用smartindent,而使用以下内容(在您的 .vimrc ):

As has been pointed out in a couple of answers below, the preferred method now is NOT to use smartindent, but instead use the following (in your .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


在您的 .vimrc:文件中:


这篇关于Tab键== 4个空格,在Vim中花括号后自动缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:00
查看更多