How do I set the cursor to stop when it hits the end of a line in Vim?

3

(Disclamer: I'm new to Vim.)

I've mistakenly managed to enable cursor movements to travel anywhere on the screen, i.e. beyond end of lines. This makes it very tedious to spot redundant whitespaces, etc.

What setting might it be that I've touched to accomplish this messy behavior? And how do I set it back to a behavior that stops the cursor when it hits the end of a line?

Henrik

Posted 2012-04-27T16:57:44.643

Reputation: 495

Answers

2

This behavior is controlled by the 'virtualedit' option. Execute

:set ve?

to see what it's currently set to. It will probably be "all". If that's the case, just execute

:set ve=

to reset it. If your Vim behaves this way all the time, you can execute

:verbose set ve?

to see where it was last set and fix the problem there. Also see

:help 've'

garyjohn

Posted 2012-04-27T16:57:44.643

Reputation: 29 085

1Ah, there we have it. Thanks! The :verbose set ve? command proved invaluable! (Seems I had defined set virtualedit=all in my .vimrc and removing it did the trick.) – Henrik – 2012-04-27T17:37:35.367