Hacker News new | ask | show | jobs
by robotvert 2909 days ago
`Ctrl + v` to visually select one character at a time (instead of say `Shift + v` that selects a whole line) and then use the movement keys to select a block of characters horizontally as well as vertically. Imagine several well indented HTML <li class="something"> elements, you could for instance delete/modify all the class attributes on all lines visually in one go (to insert text use `Shift + i`, type, then Esc).
1 comments

I think I don’t quite get you. Doesn’t “v” do the same thing?
What robotvert means is rectangular selection across multiple lines. For example, suppose you have the following text:

  <li class="wrong">first</li>
  <li class="wrong">second</li>
  <li class="wrong">third</li>
You want to change all the instances of "wrong" to "right". So you put the cursor on the first "w", then `Ctrl-V` to enter blockwise visual mode, then `e2j` to select the "wrong" words, then `c` to remove all of them and enter insert mode to type a replacement. The replacement text is then applied to each line separately. Full series of keystrokes (starting with the cursor on the "w" in the first line) if you want to follow along:

  <Ctrl-V>e2jcright<ESC>