Where is the default location for the folder ~/.vim/syntax/
on a linux system? I am trying to add a python addon. Thanks.
views:
1145answers:
3~
is a UNIX shortcut that means "the currently logged-in user's home folder", which is typically something like /users/<username>
. You should be able to find that folder by executing
cd ~
mkdir -p .vim/syntax
cd .vim/syntax
The mkdir
command creates the directory if it doesn't already exist.
If you want to add the syntax for multiple users, ire and curses is on a better track.
You are looking for the 'runtimepath' option. The documentation is pretty detailed (use :help 'runtimepath') but I'll try and summarize it here:
The runtimepath option contains a list of paths, separated by commas, where vim looks for plugins, syntax files, etc. On unix, the first path is $HOME/.vim/
(aka ~/.vim/
), which means that Vim looks for syntax files in your home folder first before it looks anywhere else. Vim looks for your extra files by searching ~/.vim/plugins/*.vim
or ~/.vim/syntax/*.vim
, depending on what type of add-ons it is loading.
The next path in runtimepath is usually /usr/share/vim/
. Vim will also search this folder for plugins etc (vim looks for /usr/share/vim/plugin/*.vim
, etc). This folder is where you should put add-ons when you want them available to every user.
The last path in runtimepath is usually /usr/share/vim/vim72/
, or whever Vim was installed to. This tells vim where to find and load add-ons which came bundled with that particular version of Vim.
Now, Most add-ons have a mechanism so that once they have been loaded from, say, your ~/.vim/syntax/
folder, they cannot be loaded from anywhere else. So even though syntax/python.vim
comes bundled with Vim and is available in /usr/share/vim/vim72/syntax/python.vim
, if an alternative version is instead loaded from ~/.vim/syntax/python.vim
, then the bundled syntax is ignored. This is how you can override bundled add-ons using your ~/.vim/
folder, and you can also override them for everyone by putting addons in /usr/share/vim/
. The other advantage of this setup is that you can always download the latest versions of the default bundled plugins without overriding any custom plugins you may have added.
If you were to put all your addons into /usr/share/vim/vim72/
, you can no longer update to the latest bundled addons without overriding your custom addons, so you should be putting addons for yourself into ~/.vim/
, or addons for all users into /usr/share/vim/
, but never into /usr/share/vim/vim72/
.