According to the Debian documentation about vim, a Debian package (Ubuntu, really, in my case) is expected to place <name>.vim files under:


Syntax files go under a sub-directory named syntax:


However, it does not look like vim recognized that directory.

In my .vimrc file I have something like so:

syntax on
if !exists("my_autocommands_loaded")
  let my_autocommands_loaded=1
  au BufNewFile,BufReadPost *.cpp  setf my-syntax

Just in case, I also tried :setf my-syntax manually and I lose the syntax (which I know is what happens when a file is not found). Looking around, it sounds like the only path to a system syntax folder would be the path to /usr/share/vim/vim<version>/syntax/....

I also replaced the setf ... with so /usr/shared/vim/addons/syntax/my-syntax.vim and that works perfectly.

Is it not possible to use that addons directory? Do I need to add it in a variable? Is it necessary to have a corresponding plugin which properly activates the addons syntax?

  • Yeah, actually, I think the better bet is to add the root to 'runtimepath' since the structure you mention above doesn't have the required {packdir}/start. Take a look at the page that you're taken to when you hit the Prev link.
    – B Layer
    Jan 8, 2022 at 20:47
  • @BLayer Ah, interesting, there is a path for addons under /varr/lib/...: runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vim80/pack/dist/opt/matchit,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after Jan 8, 2022 at 20:52
  • Hmm, seems like an awful lot of system level directories are in there. Anyways, if you add /usr/share/vim/addons everything should be picked up.
    – B Layer
    Jan 8, 2022 at 20:55
  • @BLayer I was testing... That helped in the sense that it found the plugins, but it still fails finding the syntax files. (I checked with :scriptnames). At this point I don't have plugins, only syntax files. The rest is in my .vimrc file. Jan 8, 2022 at 21:19
  • 1
    Ah, okay. Someone else will have to help you with that...I gotta run.
    – B Layer
    Jan 8, 2022 at 21:26

1 Answer 1


"Addons" is just another directory that could be added to :h 'runtimepath' by :h system-vimrc. It is intended for package manager (sudo apt install vim-foobar goes here). For this reason, you're not adviced to do anything with it.

Except for this, your question is unclear to me, as the code is simply broken. If what you're trying is to extend C++ syntax then make use of :h after-directory, e.g. ~/.vim/after/syntax/cpp.vim, as usual.

  • 1
    What I'm trying to do is create a Debian package which, when installed, gives all the users access to those files. This is my own personal package. A Debian package is not expected to install files under a ~/... directory. So I am doing a sudo apt install my-package. Jan 9, 2022 at 14:14
  • @AlexisWilke Before trying to package something you should create and debug "a regular version" that works. Just manually put all files under ~/.vim and check if it's doing something at least for the current user.
    – Matt
    Jan 9, 2022 at 15:05
  • 1
    Matt, I feel that the question still stands: In a default (?) Debian installation, /usr/share/vim/addons/ is not in runtimepath, despite the fact that lots of packages install syntax files there. As you say, "It is intended for package manager". So what is the proper way to "activate" this path? Dec 10, 2022 at 5:41
  • 2
    The answer, which I forgot, is that things in addons/ are managed by vim-addon-manager. Dec 10, 2022 at 5:44
  • 1
    @JonathonReinhart That looks like my answer. It would get installed under /usr/share/vim/addons and the user has to install the script with vim-addons install <name>. I can see that the vim-scripts package offers such so I can follow that package's functionality now that I understand how it work (i.e. that you have to run vim-addons ...). Dec 10, 2022 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.