Add `autocmd` to automatically expand the `_template` snippet on the `BufNewFile` event, if the expansion fails because the `_template` snippet does not exist for the current `filetype` undo the changes. Do the same thing when the `filetype` changes to `help`, since these are `text` files to begin with the first `autocmd` has no effect.
18 lines
692 B
VimL
18 lines
692 B
VimL
augroup benieAugroup
|
|
autocmd!
|
|
|
|
" Reopening a file at last curson position
|
|
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
|
|
\ | exe "normal! g'\"" | endif
|
|
|
|
" Highlight conflict markers in any filetype
|
|
au FileType * call matchadd('Todo', '^\(<<<<<<<\||||||||\|=======\|>>>>>>>\)\s\ze.*$')
|
|
|
|
" Read template into buffer then send line 1 to the black hold register
|
|
au BufNewFile todo.md read ~/.vim/templates/skeleton.todo.md | 1delete _
|
|
" Attempt to expand snippet named `_template` if it exists
|
|
au BufNewFile * silent! call snippet#template()
|
|
" Do the same when filetype changes to help
|
|
au FileType help silent! call snippet#template()
|
|
augroup END
|