简体   繁体   English

Vim自动缩进不正确

[英]Vim autoindent indents incorrectly

When writing code in vim, I've noticed that it sometimes messes up the indentation of the current line after pressing return. 在vim中编写代码时,我注意到按回车键后有时会弄乱当前行的缩进。 (In the gif, I go into insert mode, with the cursor at the end of the date function. When I press return, the whole "echo date('Y');" part looses its indentation when it should not). (在gif中,我进入插入模式,将光标放在date函数的末尾。当我按return键时,整个“ echo date('Y');”部分在没有应有的情况下会缩进其缩进)。

VIM

I have a ton of directives in my vimrc to try and stop all kinds of autoindentation, but much to my irritation, the problem persists. 我在vimrc中有大量指令来尝试停止各种自动缩进,但是令我感到不安的是,问题仍然存在。

filetype plugin indent off
filetype plugin off
set noautoindent
set nosmartindent
set nocindent
set indentexpr=''
let b:did_indent = 1
set ft?
filetype indent off

I wish there was a way to have vim indent files much like your "more standard" text editors, whereby they don't try to be smart, but just maintain the current indentation of the current line in the new line. 我希望有一种方法可以使vim缩进文件,就像您的“更标准”的文本编辑器一样,它们不会试图变得聪明,而只是在新行中保持当前行的当前缩进。 Like this: 像这样:

gedit中

Is this possible? 这可能吗?

仅在我的VIM上需要set smartindent才能获得gedit显示的效果。

So it seems that this line was causing the first issue displayed in the vim. 因此,似乎该行引起了vim中显示的第一个问题。 Its part of the Vundle plugin manager inclusion code: Vundle插件管理器包含代码的一部分:

filetype plugin indent on

Ensuring that my indent rules were after this fixed the problem completely. 在此之后确保我的缩进规则可以完全解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM