根据文件类型更改Vim缩进行为 [英] Changing Vim indentation behavior by file type
问题描述
您可以添加 .vim
文件,以便在vim切换到特定文件类型时执行。
例如,我有一个文件〜/ .vim / after / ftplugin / html.vim
与此内容:
setlocal shiftwidth = 2
setlocal tabstop = 2
哪个导致vim使用宽度为2个字符的标签用于缩进(在我的配置中, noexpandtab
选项设置在其他地方)
这里描述: http://vimdoc.sourceforge.net/htmldoc/usr_05。 html#05.4 ,向下滚动到filetype插件的部分。
Could someone explain to me simply the easiest way to change the indentation behavior of vim based on the file type? For instance if I open a python file it would indent with 2 spaces, but if I open powershell it would use 4 spaces.
You can add .vim
files to be executed whenever vim switches to a particular filetype.
For example, I have a file ~/.vim/after/ftplugin/html.vim
with this contents:
setlocal shiftwidth=2
setlocal tabstop=2
Which causes vim to use tabs with a width of 2 characters for indenting (the noexpandtab
option is set globally elsewhere in my configuration).
This is described here: http://vimdoc.sourceforge.net/htmldoc/usr_05.html#05.4, scroll down to the section on filetype plugins.
这篇关于根据文件类型更改Vim缩进行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!