我对VIM很陌生,一直在使用bundle来格式化/着色/缩进我的文件.我目前从这里下载了一个打字稿
vim语法“bundle”:
https://github.com/leafgarland/typescript-vim.git,问题是缩进对我来说似乎打破了,考虑下面的例子,在autoindenting(gg = G)之后的文件:
module Module { class Foo { // some string here bar: string; // bar is incorrectly indented } }
实际上我希望如下:
module Module { class Foo { // some string here bar: string; // bar is correctly indented } }
这是typescript.vim ftplugin文件:
compiler typescript setlocal autoindent setlocal cindent setlocal smartindent setlocal indentexpr& setlocal commentstring=//\ %s
我尝试摆弄不同的缩进设置无济于事.我正在使用我的VIM设置并从这里捆绑:https://github.com/gisenberg/.vim,我使用git在本地计算机上同步这些文件.
TIA!
解决方法
根据
Vim indentation documentation,您应该能够尝试以下内容,看看是否适合您.
手动摆弄
If you change the current line’s indentation manually,Vim ignores the
cindent settings for that line.
由于TypeScript中此模式的频率,这可能会令人讨厌.
尖括号
If you really want to re-indent when you type
:
use<:>
.
这会让你缩进,而不会丢失任何有用的cindent部分.
改变cinkeys
这包含影响cindent设置的设置,默认情况下为:
"0{,0},0),:,0#,!^F,o,O,e"
但是你可能会有一些运气改变它:
"0{,e"
Ditch Cindent
setlocal cindent
我已经介绍了很多选项,因为这是Vim的本质,这就是代码编辑的本质 – 您需要尝试选项以找出最适合您的选项.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。