New to vimscript. I'm writing a function that I want to be able to clear the contents of the current buffer and write this to the corresponding file (or alternatively, clear the contents of the file and then reflect this in the buffer). What I have so far is to basically have my mapping call the function and then after run the editor commands
:w<CR>, but it seems like there is probably a more elegant way to do this, no?
function MyFunction() ... some things ... endfunction nnoremap <CR> :call MyFunction()<CR> <bar> gg0dG <bar> :w<CR>