如何在 Vim 中为不同语言设置不同的选项卡设置? [英] How do I set up different tab settings for different languages in Vim?
本文介绍了如何在 Vim 中为不同语言设置不同的选项卡设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 .vimrc 中,我有一个通用的两个空格的制表符设置,我想在每种语言的基础上覆盖它(即,四个用于 Python 等,否则使用默认值),但我找不到任何好的例子.>
In my .vimrc I've got a generic tab setting of two spaces, and I'd like to override that on a per language basic (that is, four for Python, etc, otherwise use the default), but I'm having trouble finding any good example of this.
推荐答案
只需将设置放入filetype插件文件中即可~/.vim/ftplugin/LANGUAGE.vim .我的 ~/.vim/ftplugin/perl.vim 包含以下行:
Just put the settings into the filetype plugin file ~/.vim/ftplugin/LANGUAGE.vim . My ~/.vim/ftplugin/perl.vim contains the lines:
"
" ---------- tabulator / shiftwidth --------------------
" Set tabulator and shift width to 4 (Perl Style Guide)
"
setlocal tabstop=4
setlocal shiftwidth=4
"
这些设置将自动对每个文件类型为perl"的文件生效(新的或现有的).
These settings will automatically be in effect for each file with file type 'perl' (new or existing).
这篇关于如何在 Vim 中为不同语言设置不同的选项卡设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文