Vim: Selecting Text (Visual Mode) Cheat Sheet

To select text, enter visual mode with one of the commands below, and use motion commands to highlight the text you are interested in.

Then, use some command on the text.

The operators that can be used are:

  • ~ switch case
  • d delete
  • c change
  • y yank
  • > shift right
  • < shift left
  • ! filter through an external command
  • = filter through ‘equalprg’ option command
  • gq format lines to ‘textwidth’ length
vStart Visual mode per character
VStart Visual mode linewise (horizontal selection)
CTRL-VStart Visual mode columnwise (vertical selection)
<Esc>Exit Visual mode without making any changes
viwVisually select inner word (where the cursor is positioned)

Leave a Reply

Your email address will not be published. Required fields are marked *