I am having a problem with vim autocorrection. I got this line from a website, which is:

inoremap <C-l> <Esc>[s1z=`]a

The problem is that whenever I press Ctrl+l to correct something, it brings me to the end of the file, but I want it to bring the cursor back to where I pressed Ctrl+l. Does anyone have a solution for this?

1 Answer 1


My version of the mapping (which mostly works, unless the replacement made the text longer, in which case you end up in the wrong spot), is as follows (<C-g>u used to break up the undo sequence):

inoremap <C-L> <C-g>u<Esc>[s1z=gi<C-g>u

gi should work slightly better than the ] mark, which is the last-changed text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.