3

I understand that when in insert mode the cursor is described as between characters, and when in normal mode the cursor is supposed to be on a valid character. I have been having a lot of trouble with this behavior recently.

If I enter insert mode I will use _ to represent the cursor

and append some text to the end of a line_

When I exit insert mode the cursor is dropped to the beginning of the line below it so I would end up here:

and append some text to the end of a line
_

This really breaks up my flow when I am typing and I would like to modify the behavior so that the cursor is instead left at the end of the line. Since there is no character there ...

I know it wont just stay here_

But I would prefer it if the cursor just moved to the character before when I exit insert mode

So I would end up her_

Pretending there is an e at the end of that line and I have the cursor on it.

Does anyone know a way to achieve this? All of the documentation I have read suggests that this is the normal behavior anyway.

I have remapped <esc> to jk but if I remove that from my .vimrc I still en up at the beginning of the next line

  • 6
    So you have crap in your vimrc, but you don't want to show it. – VanLaser Oct 4 '15 at 22:06
  • @VanLaser I would gladly show it. But it has nothing to do with the question, as I mentioned above. You can look at my vimrc, and all of the related fiels they are in the vim directory. Perhaps after if you have something constructive to add you can grace us with your infinite wisdom on my "crap". Thanks for your help – Ajay Oct 5 '15 at 0:05
  • @Ajay can you reproduce this behaviour with vim -Nu NONE? – muru Oct 5 '15 at 0:30
  • 3
    @Ajay It does, indeed. – muru Oct 5 '15 at 0:33
  • 6
    So that was crap in your vimrc, after all. – romainl Oct 5 '15 at 5:06
4

Thanks to the comment by @muru I was able to figure this out. I turns out in my .vimrc I had this line to remap jk to <esc>

inoremap jk <esc>

but there was a space inserted at the end of the line. If I remove the space the problem is fixed. I did not realize that white space characters were important when making these customization.

This blog pointed out that any characters used (even white-space) when remapping commands were interpreted.

  • 1
    Interesting. I don't even use remapping because I like keeping my habits fully portable as a sysadmin, but this is good to know. – Wildcard Oct 5 '15 at 8:05
  • @Wildcard One day you might do a remap during a session. – Kyle Strand Oct 19 '15 at 6:30

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.