How to add new snippets to snipMate in VIM

后端 未结 6 655
遥遥无期
遥遥无期 2021-02-08 07:03

Ive just started using the sniptMate plugin for VIM and love it, however, since my collection of snippets isn\'t huge, I\'d like to be able to add new snippets dynamically rathe

6条回答
  •  無奈伤痛
    2021-02-08 07:41

    I'm not sure it's meant to be done like this but you can try calling the MakeSnip function from within file you're currently working on. For example:

    :call MakeSnip(&ft, "foo", "${1}")
    

    &ft will pass the filetype of the file you're currently editing, "foo" is the trigger and "${1}" is the replacement text.

    Of course, snippets created like this won't persist. So why not have the snippets file open in another buffer, define new snippets there as necessary, then do:

    :call ReloadSnippets(&ft)
    

    and your new snippet will be available. You could even define an autocmd to call the ReloadSnippets function when you write the snippets file.

提交回复
热议问题