Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a block replace mode in vim?

Tags:

vim

Suppose I have the following text.

Foo Bar Foo Foo Bar Bar Bar
Foo Bar Foo Foo Bar Bar Bar
Foo Bar Foo Foo Bar Bar Bar
Foo Bar Foo Foo Bar Bar Bar
Foo Bar Foo Foo Bar Bar Bar
Foo Bar Foo Foo Bar Bar Bar

If I wanted to replace the the first n characters on every line, I would normally perform the following three steps

  1. Use visual block mode to select and delete the first n characters in every line.
  2. Select the first character of every line using visual block mode.
  3. Type I, and then type the replacement text.

However, there is a faster option when we are operating on one line of text, and that is to use REPLACE mode, which we can get by hitting R in normal mode and then simply typing over the text.

Is there an equivalent REPLACE mode which operates on multiple lines?

The closest thing I could find was to Visual Block select an entire grid of characters, and then hit lowercase r, and type a single character. However, this only works if the replacement text is all the same character, and requires that I know the number of characters I want to replace a priori.

like image 902
merlin2011 Avatar asked Jul 17 '26 19:07

merlin2011


1 Answers

Use c to make a change over a block of text.

Please see:

:h v_b_c
like image 95
Peter Rincker Avatar answered Jul 20 '26 10:07

Peter Rincker