In Vim I want to have a conditional statement in a Key mapping.
If the cursor is at the start of a line, I want this mapping:
imap <F1> <ESC>:syntax sync fromstart<CR>i
but otherwise have this mapping (the only difference is the final character)
imap <F1> <ESC>:syntax sync fromstart<CR>a
In the second mapping the cursor is not put back into the correct place if this mapping is run when the cursor is at the start of a line (when we go back into insert mode with the a )
I'm trying to find for a solution to this specific problem, but I also want to know if you can indeed you put a conditional in a Vim keymapping.
Thanks!
inoremap <C-Del> <Esc>ldei
Where I have the same problem with the final i at the end. Any thoughts on that? – Repellent