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.
This commit is contained in:
parent
bdea77f86a
commit
72fe59ffaa
@ -78,3 +78,11 @@ function! do#debug(...)
|
|||||||
endfor
|
endfor
|
||||||
exec l:command
|
exec l:command
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! do#last_change()
|
||||||
|
if &filetype ==# 'help'
|
||||||
|
" vint: next-line -ProhibitCommandRelyOnUser -ProhibitCommandWithUnintendedSideEffect
|
||||||
|
1s/Last change: \zs.*$/\=strftime('%Y %b %d')/e
|
||||||
|
norm!``
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
@ -9,7 +9,7 @@ augroup benieAugroup
|
|||||||
au FileType * call matchadd('Todo', '^\(<<<<<<<\||||||||\|=======\|>>>>>>>\)\s\ze.*$')
|
au FileType * call matchadd('Todo', '^\(<<<<<<<\||||||||\|=======\|>>>>>>>\)\s\ze.*$')
|
||||||
|
|
||||||
" Update `Last change: <date>` on write then jump back previous position
|
" Update `Last change: <date>` on write then jump back previous position
|
||||||
au BufWritePost *.txt 1s/Last change: \zs.*$/\=strftime('%Y %b %d')/e|norm!``
|
au BufWritePost *.txt silent! call do#last_change()
|
||||||
|
|
||||||
" Read template into buffer then send line 1 to the black hold register
|
" Read template into buffer then send line 1 to the black hold register
|
||||||
au BufNewFile todo.md read ~/.vim/templates/skeleton.todo.md | 1delete _
|
au BufNewFile todo.md read ~/.vim/templates/skeleton.todo.md | 1delete _
|
||||||
|
Loading…
x
Reference in New Issue
Block a user