Reputation: 85
Lets say i have the following text.
this.is.some.text
this.is.emos.text
this.is.some.text
this.is.emos.text
I want to edit this text in 'Visual Block' mode so that the text looks as follows.
this.is.some.text
this.is.emos_suffix.text
this.is.some.text
this.is.emos_suffix.text
It should work like this:
Upvotes: 0
Views: 158
Reputation: 196556
The only native way to accomplish that from visual-block mode or any other visual mode is to use a substitution:
:'<,'>s/emos/&_suffix<CR>
where…
:
,'<,'>
for you, meaning "from the fist selected line, :help '<
, through the last selected line, :help
'>`,s/emos/&_suffix
substitutes every first occurrence of emos
on each line of the given range with itself, :help s/\&
, followed by _suffix
.Visual selection is often an unnecessary step and, in this case, visual-block mode is totally useless because A
or I
is going to operate on every line of the selection anyway.
Another method:
/emos/e<CR>
a_suffix<Esc>
n
.
Another one:
/emos<CR>
cgn<C-r>"
_suffix<Esc>
.
Another one, assuming the cursor is on the first line of your sample:
:,'}s/emos/&_suffix<CR>
Etc.
Upvotes: 5