Created
June 13, 2015 00:43
-
-
Save dahu/0009113ebac81bba6c10 to your computer and use it in GitHub Desktop.
auto manage begin/end blocks in log file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Barry Arthur, June 2015 | |
" Auto manage Begin/End blocks in log file | |
" Manual function to create new block | |
function! SpasmLogAuto() | |
if ! exists('b:spasm') | |
let b:spasm = 1 | |
$ | |
let now = strftime('%c') | |
let last_entry = search('^\(Begin\)\|^\(End\)', 'bcpW') | |
if last_entry == 0 || last_entry == 3 | |
call append('$', 'Begin ' . now) | |
else | |
call append('$', ['End','Begin ' . now]) | |
end | |
$ | |
endif | |
endfunction | |
function! SpasmLogManual() | |
silent! unlet b:spasm | |
call SpasmLogAuto() | |
endfunction | |
augroup SpasmLog | |
autocmd BufWinEnter *.log silent call SpasmLogAuto() | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment