2

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.

Is this possible?

  • 4
    this is not possible in Vim. – Christian Brabandt Sep 23 at 18:10
  • Not sure what your final goal is, but Iselect may help. It lets you select lines and output them to a file. I have just found it and describe its basic usage here. – Quasímodo Sep 23 at 21:04
  • Are you sure you don't mean V to do a line-wise visual selection? <C-v> does a block-wise visual selection. – Jake Grossman Sep 23 at 21:57
  • 1
    What is your actual goal (post-selection)? :global/1\|3/ will let you run an action on only those two lines... – D. Ben Knoble Sep 23 at 22:31
  • Welcome to Vi and Vim! – filbranden Sep 23 at 22:55
1

From :h visual-use (emphasis mine):

Using Visual mode consists of three parts:

  1. Mark the start of the text with "v", "V" or CTRL-V. The character under the cursor will be used as the start.
  2. 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.
  3. 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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