Replace a Block of Text in Vim

Select the block of text:

1. Position the cursor at the beginning of the text you want to replace

2. Press v to enter visual mode. (or upper case V to select whole lines, or Ctrl-v for a vertical block).

3. Move the cursor to the end of the text to be replaced. (While selecting text, you can perform searches and other advanced movement, a feature that sets vim apart from most other editors.)

4. Press c. This deletes the selection and leaves you in insert mode.

5. Type your replacement text.

Leave a Reply