Can we use multiple snippet files for given filetype in vim?

Viewed 4275

When using snipmate + vim, is it possible to have many snippet files load for a given language/filetype?

Ex: snipmate comes with javascript.snippets I've also loaded the mootools snippets and added this to my vimrc: autocmd FileType javascript set ft=javascript.mootools

Now I can use

  • the stock js snippets
  • the mootools snippets

I want to add a 3rd set of snippets, javascript.myCustomSnippets, that will also load for the filetype javascript.

When I try to add my custom snippets using something like this autocmd FileType javascript set ft=javascript.myCustomSnippets it overwrites/disables the mootools snippets, however the default javascript snippets continue to work.

How do I accomplish this, or is it possible?

ps: I know I could just add my snippets to the default javascript snippets file, but since I have the snipmate github repo synced inside my .vim/bundle/ folder, I want to keep the personal stuff separate from the live repo.

My Solution

The specific solution that finally got my files working side-by-side was to structure my files like this (by the way, I'm using pathogen to auto-load the bundle dir)

~/.vim/bundles/
    snipmate.vim/snippets/javascript.snippet
    vim-snippets.mootools/snippets/mootools.snippet
    vim-snippets.myCustomSnippets/snippets/javascript.snippets

By naming my file "javascript.snippets" it's auto-loaded along with the defaults.

5 Answers
Related