How can I automatically add some skeleton code when creating a new file with vim

后端 未结 8 1434
清歌不尽
清歌不尽 2020-11-29 02:42

When creating a new file with vim, I would like to automatically add some skeleton code.

For example, when creating a new xml file, I would like to add the first lin

8条回答
  •  误落风尘
    2020-11-29 03:04

    It can work with snipmate too:

    augroup documentation
        au!
        au BufNewFile *.py :call ExecuteSnippet('docs')
    augroup END
    
    function! ExecuteSnippet(name)
        execute "normal! i" . a:name . "\=TriggerSnippet()\"
    endfunction
    

    with "docs" the snippet to trigger.

    It works with multi-snippets but then the :messages window appears and it's cumbersome.

提交回复
热议问题