If you have the following text:
line 1
line 2
line 3
You can hit CTRL+v on line 1 and hit j to select line 2. However, I want to select both line 1 and line 3, but not line 2.
Or, select multiple arears like this:
Is this possible?
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 communityFrom :h visual-use
(emphasis mine):
Using Visual mode consists of three parts:
- Mark the start of the text with "v", "V" or CTRL-V. The character under the cursor will be used as the start.
- Move to the end of the text. The text from the start of the Visual mode up to and including the character under the cursor is highlighted.
- Type an operator command. The highlighted characters will be operated upon.
You cannot exclude certain portions. Visual mode will select all of the text between the start and end of the selection. The only caveat is that block-wise visual mode will select a rectangle of text, rather than line by line up to and including the cursor.
If you're using vim on vscode
, you can hold the option/alt
key and click on the other line, it will put a cursor there, then you can shift + v
it.
V
to do a line-wise visual selection?<C-v>
does a block-wise visual selection.:global/1\|3/
will let you run an action on only those two lines...