Linux/Ubuntu directory location ~/.vim/syntax/

后端 未结 4 864
时光说笑
时光说笑 2021-01-30 09:23

Where is the default location for the folder ~/.vim/syntax/ on a Linux system? I am trying to add a Python addon.

相关标签:
4条回答
  • 2021-01-30 09:56

    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/plugin/*.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/.

    0 讨论(0)
  • 2021-01-30 10:00

    /usr/share/vim/vim72/syntax/

    I added the file in the above location and it is working for puppet scripting

    0 讨论(0)
  • 2021-01-30 10:02

    From the docs:

    $VIMRUNTIME/syntax
    

    On my (Ubuntu) machine, this is /usr/share/vim/vim72/syntax/.

    0 讨论(0)
  • 2021-01-30 10:14

    ~ 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.

    0 讨论(0)
提交回复
热议问题