I want to execute the command "yiw:s/\<<C-r>"\>/<C-r>"/g<Left><Left>"
by key sequence.
So I make a mapping
nnoremap <F7> yiw:s/\<<C-r>"\>/<C-r>"/g<Left><Left>
This mapping copy the word under cursor, then the string :s/\<">/"/g" (where " are substituted by the copied word) appears in the command line and the cursor in the command line is at the end of replacement statement.
I also want to save cursor position before this command and restore after.
function! SafeCommand(cmd)
let line = line('.')
let col = col('.')
// execute cmd here
call cursor( line, col )
endfunction
How to do that?