I have a function that depends on the character under the cursor : if it's a
), then the function does nothing ; if it's not, the function adds a
function! Ket() let char = getline(".")[col('.')-1] if char != ')' execute "normal! a)\<esc>" endif endfunction
If I call it from normal mode, using
:call Ket(), it works fine.
But I have it remapped from insert mode, as follows :
inoremap ) <Esc>l:call Ket()<CR>a. This mapping should (from my understanding) :
- escape insert mode with
- go one character to the right with
l(because escape to normal mode moves the cursor to the left),
- call my
- get back to insert mode (
If I am in insert mode, and my cursor is on a
) character, then I get what I expect by pressing ) : the cursor moves to the right, and I end up in insert mode.
But if my cursor is on any other character, pressing ) only escapes insert mode, as if I had pressed Esc.