vim/plugin/autocmds.vim
Kenneth Benzie (Benie) 72fe59ffaa Only invoke last change substitution in help files
Previously the `autocmd` to replace the date on the first line if `Last
change: ` was present resulted in the cursor being moved in non `help`
filetypes due to the substitution failing. Now the substitution is only
attempted if the current file is a `help` file.
2019-04-04 16:53:46 +01:00

21 lines
822 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.*$')
" Update `Last change: <date>` on write then jump back previous position
au BufWritePost *.txt silent! call do#last_change()
" 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