how to stop vim moving javascript object keys to column 0
When typing javascript object literals, such as:
foo = {
bar: baz
};
vim thin开发者_JAVA技巧ks "bar:" is a C-style label and moves it to column 0.
How do I stop this?
Try :set cinkeys-=:
.
Label indentation cannot be controlled by cinoptions
. To quote from :help indent
Vim puts a line in column 1 if:
- 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.
(Emphasis mine)
However, cinkeys
specifies which keys trigger reindenting in insert mode. By removing :
from cinkeys
, vim will no longer reindent on inserting :
.
But be aware that manual re-indenting via =
will still break your layout.
精彩评论