visual mode

範圍Selection

  • v visually select the current character, use any motion command to extend the selection
  • ve selects till the end of a word
  • vip selects a paragraph (text object) and so on
  • V visually select the current line, you can extend this using motion commands
  • Vgg selects the current line and then extends to the start of the file
  • Ctrl+v visually select column(s)
  • Ctrl+v followed by 3j2l selects a 4x3 block
  • you can also select using the mouse and then press Ctrl+v
  • gv select previously highlighted visual area
  • o move the cursor to the diagonally opposite corner of the visual selection
  • O move the cursor to the other corner of the current line in visual block selection
  • Esc go back to Normal mode
  • info Pressing $ in block selection will select until the end of lines for the selected area, even if the lines have different number of characters. This will continue to be the case if you extend the selection with up/down motions.

Editing

  • d delete the selected text
  • y yank (copy) the selected text
  • p replace the selected text with contents of the default " register
  • See :h v_p for more details, corner cases, uppercase P command behavior, etc
  • c clear the selected text and change to Insert mode
  • for block selection, you can type text and press Esc key to replicate that text across all the visually selected lines
  • C similar to c but clears till end of lines before changing to Insert mode
  • I for block selection, press I, type text and press Esc key to replicate that text across all lines to the left of the column
  • text will not be inserted for lines shorter than the starting column of selection
  • if you type multiline text, it will not get replicated
  • A for block selection, press A, type text and press Esc key to replicate that text across all lines to the right of the column
  • if $ was used for selection, text will be inserted only after the end of respective lines
  • otherwise, text will be inserted after the selected column and space characters will used to extend shorter lines if any
  • if you type multiline text, it will not get replicated
  • ra replace every character of the selected text with a
  • : perform Command-line mode editing commands like g, s, !, normal, etc on the selected text
  • J and gJ join lines using the same rules as seen in Normal mode
  • info Press Ctrl+c if you've typed text after using I or A but don't want to replicate the text across all the lines.