I added two normal mode mappings so that the cursor doesn't move when changing case

nnoremap gUiw m0gUiw`0
nnoremap guiw m0guiw`0

Recently I had to uppercase a word and I tried like this:


which turned into:


Obviously, there is something conflicting between normal mode mapping and :h i_CTRL-O workflow. What is it?

PS I'm running NVIM v0.4.0-dev


i_CTRL-O allows one command to be executed before returning to insert mode. With your mapping the first command is setting the mark 0 (m0). After that was executed, Vim returns to insert mode.

One solution would be a insert mode mapping:

:inoremap <C-G>Uiw <C-C>m0gUiw`0a
  • But shouldn't there be a way to do something like noremap so that when I do i_CTRL-O, it doesn't check my mappings? There should be.
    – klaus
    Mar 25 '19 at 8:09
  • @klaus This is where I like Drew Neil’s advice about resting with your paintbrush off the canvas (or, in Normal mode, as it were)—one can try to cram this weird corner case into working, but it’s probably easier and may be a better habit to just hit escape and do your edits. Thats what Normal mode is for.
    – D. Ben Knoble
    Mar 25 '19 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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