Reputation:
I would like to run the c.vim plugin for VIM for not just c/cpp files but also for python files. I have already made all the custom templates for python.
When I create a new python file the c.vim does insert the automatic header that I have in the python template. However the shortcuts dont seem to work.
I am not able to figure out what else needs to be set to make it work.
Thank You for the help.
Upvotes: 2
Views: 94
Reputation: 21492
There is a way to make snippets for both C and Python file types using neosnippet
plugin.
Install the plugin and configure the key mappings:
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
You might want to use Honza's snippets as well as your own:
let g:neosnippet#snippets_directory = [ '~/.vim/bundle/vim-snippets/snippets',
\ '~/.vim/my-neosnippets' ]
Create ~/.vim/my-neosnippets/python/python.c.snippets
file with custom snippets, for instance:
snippet [
[${1}]
Then create a symbolic link to this file:
├── c
│ └── c.python.snippets -> ../python/python.c.snippets
└── python
└── python.c.snippets
Now you can use python.c
file type for Python files:
# vim: ft=python.c
And c.python
file type for C files:
/* vim: set ft=c.python: */
If you don't like the idea to put modelines in every file, then you can use the rule for all C and Python files:
au FileType,BufRead c set ft=c.python
au FileType,BufRead python set ft=python.c
Upvotes: 1