Reputation: 35308
Is there any way in vim that I can select the end of all these lines? (I'm only showing the end of the lines in these screenshots).
In block mode I can get them all if the bottom line is longer than the rest, but if the bottom line is shorter, the longer lines are truncated.
EDIT | I guess I can just pad out the bottom line with spaces before I select, then delete the spaces later.
Upvotes: 43
Views: 26014
Reputation: 178
I don't know if is a new thing. But if you press $
two times (instead one) the block goes to the end of all lines without creating extra spaces).
Tested on nvim 0.7.2.
Upvotes: 0
Reputation: 1122
Click somewhere (anywhere) in the first line you wish to append text to.
Press Control + V.
Press Down to create an arbitrary vertical block selection that spans the desired lines.
Press $ to expand the visual block selection to the ends of every line selected.
Press Shift + A to append text to every selected line.
Type the text you want to append.
Press Escape and the text will be appended across the selected lines.
Upvotes: 22
Reputation: 4522
If you're looking to select the very last character of every line, like if you want to add something after the quotes at the end of each line, you can do the following:
Hope this is helpful to others like me searching for an answer similar, but not exactly the same, as the above.
Upvotes: 14
Reputation: 7074
Alternately, you can set the virtualedit
(:h 'virtualedit'
) setting so that, any time you're in visual block mode, you can move the cursor around even past the ends of lines. E.g. :set virtualedit=block
.
Upvotes: 17
Reputation: 30043
There's more information in the Vim documentation's section on visual mode which you can read online, or just type :help v_$
in Vim.
Upvotes: 75