Multiple autocommands in vim

前端 未结 3 1656
我在风中等你
我在风中等你 2020-12-23 15:54

I\'ve got some sections in my .vimrc that look like this:

autocmd Filetype ruby setlocal ts=2
autocmd Filetype ruby setlocal sts=2
autocmd Filet         


        
3条回答
  •  鱼传尺愫
    2020-12-23 16:26

    ftplugins are the neat answer to your question.

    1. Ensure your .vimrc has a line such as :filetype plugin on
    2. Define a file named {rtp}/ftplugin/{thefiletype}.vim or {rtp}/ftplugin/{thefiletype}/whatever.vim (see :h rtp for more details).
    3. Edit this new file and put your VIM commands in there. It is probably a good idea to use the :setlocal command to ensure filetype-specific settings are only for that file (e.g., don't turn all comments purple across all filetypes).

    See examples in vim distribution if you plan to override default settings ; or among the many ftplugins I wrote otherwise), just write down your :setlocal, :*map , etc. definitions.

    It represents some more line to type, but at least, it does scale.

提交回复
热议问题