Jorenar / miniSnip

Lightweight snippet plugin for Vim
MIT License
53 stars 8 forks source link

Expanding from an autocmd #11

Closed eemed closed 4 years ago

eemed commented 4 years ago

I am using skeleton files to template certain filetype files. I would like to move these to use miniSnip functionality for vimscript evaluation. Is it possible to trigger a certain snippet from an autocmd BufNewFile?

Jorenar commented 4 years ago

Yes, it is possible by combining :h :normal and :h i_CTRL-R_=. For example, to insert snippet hello into C file:

autocmd BufNewFile *.c exec "norm! i" . 'hello' . "\<C-r>=miniSnip#trigger()\<CR>"