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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou 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.