Kirill Ermolov
Kirill Ermolov

Reputation: 810

How to replace word without changing line length in VIM

I have file:

word          some other word

(10 spaces after word)

I want to replace word without change line length

Example:

new word      some other word

(6 spaces after word)

Is it posible in vim?

I now only one solution c l 8 but I should know length of new word to do it.

Upvotes: 1

Views: 68

Answers (1)

Randy Morris
Randy Morris

Reputation: 40947

You can use R to enter Replace mode. This allows you to type new word "over" word without modifying the amount of space. The downside of this is if you wanted to replace a longer word with a shorter word you would have to "blank" out the extra characers from the old word.

See :help R and :help gR for more info.

Upvotes: 2

Related Questions