I want to use $ in visual mode but it always includes a trailing space (even if there isn't one on the line).

How do I make it so $ only goes to the actual last letter?

1 Answer 1


You can control that with the 'selection' option. To disable the "past line" cursor behavior, use the following command:

set selection=old

Beware that using a non-default setting for this option is possibly likely to break behavior of some plug-ins, so it might not be a great idea to change it.

There's also a motion that might be close to what you want: g_ moves to the last non-blank character of the line. It's not exactly the same as $ with selection=old. For example, when there are trailing blanks. Also, using $ will keep the cursor at the last character of the line as you move up or down, which is not the case if you used g_.

But g_ will work without having to mess with the 'selection' setting, so it's better in that sense.

  • 1
    Awesome, g_ is also fairly easy enough to type. Thanks!
    – Tallboy
    Jul 15, 2020 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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