Reputation: 2493
I like to use "*" to search text in vim. after hight light the target text, I want to edit all of them, is there any way I can do it in vim? for example, after highlight text, I just need to press ctrl+i then the highlight text can be edited simultaneously
Upvotes: 1
Views: 144
Reputation: 45087
As a nice alternative. You can use gn
and the .
command.
*
or /foo
c
operator over the gn
motioncgnbar<esc>
will change the highlighted area to bar
..
too repeat this change. You can also use n
to skip places.Note: This requires at least 7.4
For more help see:
:h gn
:h .
Upvotes: 2
Reputation: 820
If you wish to edit the word with another you can use the substitute
command. (e.g. :%s/hi/hello/g
)
This will change all occurrences of hi
to hello
in the file.
Upvotes: 0
Reputation: 31040
You can check out the vim-multiple-cursors plugin.
Personally, I like @Ingo's solution. The less plugins the better.
Upvotes: 1
Reputation: 172510
Simultaneous editing (like seen in other editors) is not built into Vim (but there are plugins). You don't need them, though. After *
, the text is stored in the last search pattern register, and you can just :substitute//
without repeating what you're searching for:
:%s//replacement/g
The %
is a range and applies this to the whole buffer; the /g
is a flag that replaces all (globally) instances, not just the first in each line. Read :help :s
for details.
Upvotes: 9