I am trying to create a new snippet to my snipMate plugin.
I work with some files called (i.e.) myfile.endfile
All .endfile files should have the same "snippet" like .html files. So I did
cp html.snippet endfile.snippet
in my ~/.vim/snippets directory.
SnipMate is working with all present snippets, but not with my new created one. Any suggestions for this problem?
(Btw: after creating the new .snippet file, I ran :helptags ~/.vim/doc
command in an vim instance.)
It is because Snipmate works with filetype
, which is a Vim option set when opening a file of a particular type.
For exemple, if you are opening, "index.html" the filetype
is automatically set to html
.
To see how it works, do :
:e $VIMRUNTIME/filetype.vim
As a preliminary test, you can :
1. open test.endfile
2. type :set ft=endfile
or :set filetype=endfile
3. Check if your defined snippets now work
To do that automatically add the following in your .vimrc :
au BufNewFile,BufRead *.endfile set filetype=endfile
It means that every time you read or create a new file ending in endfile
the filetype option is set to endfile.
(The filetype is an arbitrary string it doesn't have to be identical to the file extension)