vimvi

How can I select a column in multiple lines in Visual mode in Vim?


When I go to visual mode using v, I want to select a subset of one line and expand below in the same block, not select the entire next line.

For example, I want to replace all 1s by 0s. And I want to select all 1s in visual mode. But hjkl leads to select the entire next line.

enter image description here


Solution

  • As stated in the comment, ctrl-v will allow block highlighting.

    To make your edit, just position the cursor on the first 1, then hit ctrl-v. Next use the j key to move the cursor down and highlight the other 1's.

    Once you have to 1's highlighted that you want to change, r followed by 0 will replace them all with 0's.