我在Vim中遇到了一个不寻常的缩进问题,我想更好地理解它。下面的行描述了我输入的内容:
writing some words
manually indenting this line
this line got automatically indented
here's a line with a colon: some more words
this line is indented as expected
now I introduce (parentheses) and nothing happens
indented as expected
here it comes (parentheses and a colon): let the magic begin
why do parentheses+colon indent me to here?为什么它要这样做,我怎样才能让它停止呢?:)我喜欢整体上的紧张,所以我更喜欢把它放在自动缩进/智能按钮之上。
我的Vim设置是:
:verbose set ft? ai? si? cindent? indentkeys? cinkeys? cinoptions? indentexpr? formatoptions?filetype= no工缩进的小白鼠indentkeys=0{,0},0],:,0#,!^F,o,O,e cinkeys=0{0},0),0],:,0#,!^F,o,O,O,e cinoptions= indentexpr= formatoptions=tcq最后一次从/usr/share/vim/vim 81/debian.vim 3
发布于 2020-08-12 03:10:34
正如Matt提到的那样,您可能不想将cindent用于非C或C类语言,因为它有很多关于C语法的硬编码知识,这些知识通常不适用于文本,甚至不适用于Python或Ruby等其他编程语言。
你能做的就是这样:
" For general usage.
set autoindent
autocmd FileType c setl cindent noautoindent如果您使用其他语言,您可以为cpp、java等添加额外的节。您还可以使用这种类型的autocmd语句来调整缩进级别(通过ts、sts和sw)或在制表符和空格之间切换,这取决于您使用的语言的规范(例如,Ruby的2个空格或Go的8空间选项卡)。
对于文本,还可以调整formatlistpat以调整构成列表标题的内容,当启用自动缩进时,将确定是否应缩进下一行以继续列表。这可能是这里发生的事情的一部分。我为该选项使用的值是^[.-*+•]\\+\\s\\+,它不应该导致冒号被考虑。
https://stackoverflow.com/questions/63363066
复制相似问题