0

Esc doesn't work for me for obvious reasons. So I started using C-c but I'm told that's bad practice. In addition it isn't as convenient as I like it to be.

So I looked into binding C-Space and found this which toggles between insert and normal mode.

:nnoremap <C-@> i
:inoremap <C-@> <Esc>

I guess I can extend this to exiting other modes like visual to normal by using :vnoremap, etc.

This is perfect. The only problem I face is that when pressing C-Space in insert mode to switch to normal mode, the caret moves back by one position. That's quite annoying.

I also tried the nnoremap <C-Space> i version but that doesn't work on my system. I'm on an Ubuntu Focal. I read some comment that Ubuntu 14 captures that sequence or some such.

Terminal: Konsole WM: i3

I have also GNOME and KDE Plasma from when I used them.

2
  • What exactly is the question? If it’s just the cursor movement, that’s what happens when you escape (it makes sense at the end of a line, or if you consider that in normal mode your cursor is on a character, whereas in insert mode it is on the space between characters, where it will be inserting.)
    – D. Ben Knoble
    Sep 2, 2021 at 21:15
  • You are right. This movement is normal. I was probably confused and doubted my original bindings. It's my first time doing such things. Going to remove the post as it makes no sense and will probably only confuse less experienced people like myself. Thanks.
    – user1984
    Sep 2, 2021 at 21:27

1 Answer 1

2

Add an l to the end of your existing imap. This will move the cursor to the right by one position.

You might see a difference with column 1 though. I control this with an expression in a remap.

inoremap <expr> jk (col('.')==1 ? '<esc>' : '<esc>l')

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.