I use vim as a note-taking app by editing a text file and appending notes to it.
I have written a simple function to insert a block of text as follows:
function! AddBlock2(...) range
let l:hdr = strftime("_%d%b%y_%H-%M-%S")
let l:b = repeat("-", 20)
call append(line('$'), ['',l:b,'MEETING TIME : ' . l:hdr,'KEYWORDS : ',l:b, ''])
execute "normal! G$o"
endfunction
I have mapped it so that it is easy to add a new header at the beginning of a meeting:
" append header to existing buffer
:nnoremap <C-b> :call AddBlock2() <CR>
:inoremap <C-b> :call AddBlock2() <CR>
This has the effect of inserting a block like this at the end of the file:
Currently the code puts the cursor at the end of the block of inserted text because of execute "normal! G$o"
.
Ideally I would like to cursor to be placed in insert mode after "KEYWORD: "
once the text has been inserted
How could I change the code to achieve this ? I have tried replacing the last line with execute "normal! G?:a "
but it does not work at all