如何禁用 vim 的 switch case 缩进?
我目前正在与 Vim 作斗争,我似乎无法让缩进选项达到我想要的效果。
这是我的设置,我将它们放在 .vimrc 的底部以确保它们优先。正如你所看到的,我有点疯狂,所以我尝试关闭几乎所有内容:
set cindent
set cinkeys=o,O
set cinoptions=
set cinwords=
set indentexpr=
在大多数情况下,它似乎工作正常,它在打开一个块后进行一次缩进,一切都很好。但有一种情况让我发疯,当 case
语句后面有一个 {
时,下一行缩进得太远:
switch () {
case CASE: {
// <-- next line gets indented to here, why??
// <-- should be indented to here
我怎样才能让它停止做这个? TIA
I'm currently fighting with Vim, I can't seem to make the indentation options do what I want.
Here are my settings, I put them at the bottom of .vimrc to make sure they take precedence. As you can see I'm going a little crazy, so I tried turning off almost everything:
set cindent
set cinkeys=o,O
set cinoptions=
set cinwords=
set indentexpr=
In most cases it seems to work fine, it does one indent after opening a block and everything is fine. But there is one case that is driving me crazy, when there is a {
after a case
statement, the next line is way too far indented:
switch () {
case CASE: {
// <-- next line gets indented to here, why??
// <-- should be indented to here
How can I make it stop doing this? TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(即字母 ell 后跟数字一)
查看 :help cinoptions-values 了解默认字符串和不同选项的描述。
(that's the letter ell followed by a number one)
Look at :help cinoptions-values for the default string and descriptions of the different options.
如果缩进为 N 个空格(将 N 替换为实际值),请尝试以下操作
:N ->将 'case' 标签放置在距 switch 缩进 0 个字符处
=0 ->;缩进 case 标签内的语句
If indent is N spaces (replace N with actual value), try the following
:N -> place 'case' label 0 characters from switch's indent
=0 -> indents the statements within case label
当我手动键入
set
命令时,我没有任何缩进。您是否查看过:set all
的输出来确认您的设置没有被覆盖?注意:这可能应该在评论中,但目前我不允许该选项。
When I manually key in your
set
commands, I get no indentation whatsoever. Have you looked at the output of:set all
to confirm your settings are not being overridden?Note: This should probably be in a comment, but that option is presently disallowed to me.