【发布时间】:2011-01-13 01:00:06
【问题描述】:
我每天都使用几种不同的编程语言,我希望每种语言都有不同的制表符宽度(以空格为单位)。例如:我对 Ruby 使用“标准”的 2 个空格,但我们现有的所有 Matlab 代码都使用 4 个空格。
我有这个来自我的个人~/.vimrc:
augroup lang_perl
au!
set tabstop=4 " tabstop length N in spaces
set shiftwidth=4 " make >> and friends (<<, ^T, ^D) shift N, not the default 8
set expandtab " Use spaces instead of tabs
augroup END
augroup lang_ruby
au!
set tabstop=2 " tabstop length N in spaces
set shiftwidth=2 " make >> and friends (<<, ^T, ^D) shift N, not the default 8
set expandtab " Use spaces instead of tabs
augroup END
这些有效,但以下无效:
augroup lang_matlab
au!
set tabstop=4 " tabstop length N in spaces
set shiftwidth=4 " make >> and friends (<<, ^T, ^D) shift N, not the default 8
set expandtab " Use spaces instead of tabs
augroup END
我真的不明白augroup lang_ruby 是如何判断出我正在编辑一个 Ruby 文件的。 (我的搜索出现了ftdetect,但解决方案并不明显。)vim 似乎不知道我正在使用augroup lang_matlab 编辑 Matlab。我要进行哪些更改才能完成这项工作?
【问题讨论】:
-
当您在编辑 matlab (.m) 文件并键入
:set filetype?时,它是否以filetype=matlab响应?它可能会将您的 .m 文件识别为另一种语言。
标签: vim