gpt4 book ai didi

javascript - 如何停止 vim 将 javascript 对象键移动到第 0 列

转载 作者:行者123 更新时间:2023-11-29 10:53:58 26 4
gpt4 key购买 nike

当键入 javascript 对象文字时,例如:

foo = {
bar: baz
};

vim 认为 "bar:"是一个 C 风格的标签并将它移到第 0 列。

我该如何阻止它?

最佳答案

试试 :set cinkeys-=:

cinoptions 无法控制标签缩进。引用自 :help indent

如果满足以下条件,Vim 会在第 1 列中放置一行:

  • It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
  • It starts with a label (a keyword followed by ':', other than "case" and "default").
  • Any combination of indentations causes the line to have less than 0 indentation.

(强调我的)

但是,cinkeys 指定在插入模式下哪些键触发重新缩进。通过从 cinkeys 中删除 :,vim 将不再在插入 : 时重新缩进。

但请注意,通过 = 手动重新缩进 仍会破坏您的布局。

关于javascript - 如何停止 vim 将 javascript 对象键移动到第 0 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4321372/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com