Vim Tip: Visual Mode

vim_editor There’s normal mode, command mode and a third, less known to the begginers, visual mode. What’s this mode about?

Using Vim on visual mode can make some rather complex tasks and regex operations go away with a couple of keystrokes and it’s as easy as selecting the text you want with the cursor.

Move your cursor over the first part of the text you’re trying to select and press Ctrl + V to set Vim to visual mode, then move the cursor to the last part of the text you’re trying to select (it works in blocks, not character by character nor line by line… try it, it’s easier than it may seem).

What can you do after selecting text this way? Pretty much anything else you’d do with normal text, like cut (x) and paste (p). This is specially useful when working with formated text (i.e. programming).

Visual mode can also work with lines (use Shift + V insted. Notice the uppercase V) and with other modes; check the manual for more information.

Advertisements

One Comment on “Vim Tip: Visual Mode”

  1. […] “>” without anyother command will indent that line by itself; use visual mode (Shift + V) to select several lines and indent them in one keystroke. You could also press […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s