Move cursor to new line character

2017-12-07 19:01:25

When in visual mode you can select the new line character. E.g.:

The quick brown fox jumps over the lazy dog.⏎

In visual mode you can select both the period and the (invisible) carriage return, or even just the carriage return (if you delete it you'll join the current and the next lines).

In normal mode, on the other hand, I can't get the cursor on top of that character, which really annoys me. Every now and then I want to select some text including the new line before it. So I have to go to visual mode, select what I want and then type o and go back a character to select the new line. It would be a lot better if I could have the cursor on the new line to begin with, so I'd just go into visual mode and select what I want.

Any ideas on how to make that happen?

If you simply want the cursor to be able to go one past the end of the line for the purpose of starting visual mode, you want the setting set virtualedit=onemore (see :help 've). However, this does not le

  • If you simply want the cursor to be able to go one past the end of the line for the purpose of starting visual mode, you want the setting set virtualedit=onemore (see :help 've). However, this does not let you remove the new line character in normal mode (in vim you usually use J to do this).

    2017-12-07 19:16:41
  • You can use 'virtualedit' for this:

    :set virtualedit=onemore

    Note however the warnings in :help 'virtualedit':

    "onemore" is not the same, it will only allow moving the cursor just

    after the last character of the line. This makes some commands more

    consistent. Previously the cursor was always past the end of the line

    if the line was empty. But it is far from Vi compatible. It may also

    break some plugins or Vim scripts. For example because |l| can move

    the cursor after the last character. Use with care!

    2017-12-07 20:30:19