简体   繁体   中英

Where to put system-wide language-specific Vim ftplugin .vim files

I've put some language-agnostic baseline settings in /etc/vimrc , which serve as default for users unless a user overrides them.

Where is the canonical system-wide place to put the respective {language}.vim files?

On a per-user basis, I've always put these in ~/.vim/ftplugin/{language}.vim , ie ~/.vim/ftplugin/python.vim might contain:

setlocal colorcolumn=72,80

However, this only kicks in for the given user.

Where should the system-wide version of ~/.vim/ftplugin/ sit? Should I directly edit /usr/share/vim/vim74/ftplugin/python.vim , or override it somewhere else?


Info:

Output of :scriptnames :

/etc/vimrc
/usr/share/vim/vim74/syntax/syntax.vim
/usr/share/vim/vim74/syntax/synload.vim
/usr/share/vim/vim74/syntax/syncolor.vim
/usr/share/vim/vim74/filetype.vim
/usr/share/vim/vimfiles/ftdetect/dockerfile.vim
/usr/share/vim/vimfiles/ftdetect/nginx.vim
/usr/share/vim/vimfiles/ftdetect/stp.vim
/usr/share/vim/vim74/ftplugin.vim
/usr/share/vim/vim74/syntax/nosyntax.vim
/usr/share/vim/vimfiles/plugin/cctree.vim
/usr/share/vim/vim74/plugin/getscriptPlugin.vim
/usr/share/vim/vim74/plugin/gzip.vim
/usr/share/vim/vim74/plugin/matchparen.vim
/usr/share/vim/vim74/plugin/netrwPlugin.vim
/usr/share/vim/vim74/plugin/rrhelper.vim
/usr/share/vim/vim74/plugin/spellfile.vim
/usr/share/vim/vim74/plugin/tarPlugin.vim
/usr/share/vim/vim74/plugin/tohtml.vim
/usr/share/vim/vim74/plugin/vimballPlugin.vim
/usr/share/vim/vim74/plugin/zipPlugin.vim
/usr/share/vim/vim74/ftplugin/python.vim
/usr/share/vim/vim74/syntax/python.vim

Output of :h runtimepath :

'runtimepath' 'rtp'     string  (default:
                                       Unix: "$HOME/.vim,
                                               $VIM/vimfiles,
                                               $VIMRUNTIME,
                                               $VIM/vimfiles/after,
                                               $HOME/.vim/after"
                                       Amiga: "home:vimfiles,
                                               $VIM/vimfiles,
                                               $VIMRUNTIME,
                                               $VIM/vimfiles/after,
                                               home:vimfiles/after"
                                       PC, OS/2: "$HOME/vimfiles,
                                               $VIM/vimfiles,
                                               $VIMRUNTIME,
                                               $VIM/vimfiles/after,
                                               $HOME/vimfiles/after"
                                       Macintosh: "$VIM:vimfiles,
                                               $VIMRUNTIME,
                                               $VIM:vimfiles:after"
                                       RISC-OS: "Choices:vimfiles,
                                               $VIMRUNTIME,
                                               Choices:vimfiles/after"
                                       VMS: "sys$login:vimfiles,
                                               $VIM/vimfiles,
                                               $VIMRUNTIME,
                                               $VIM/vimfiles/after,
                                               sys$login:vimfiles/after")

If you want to override /usr/share/vim/vim74/ftplugin/python.vim globally put your code into $VIM/vimfiles/after/ftplugin/python.vim (it's mentioned in :help runtimepath above); $VIM is usually /usr/share/vim so the exact path is /usr/share/vim/vimfiles/after/ftplugin/python.vim . Those plugins are executed after main plugins. Per-user overrides are in $HOME/.vim/after .

Verify paths with :echo &runtimepath .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM