Bernd Strohhäcker wrote:
Dr. Johannes Zellner schrieb:

Hi,

having marked a visual block with ctrl-v, I'd like to so a search /
replace only in that visual block. E.g. when selecting the right block
in:

xx xx
xx xx
xx xx
xx xx

I'd to do something like s/xx/yy/g which applies only to the selected
block. How can I do this?


Hi,

try Charles Campell's vis-script: http://www.vim.org/scripts/script.php?script_id=1195

HTH, Bernd


Thanks for the pointer to this, it is a useful script, if Charles is out there today, just a little point, it doesn't seem to like 'c' being used in substitutions, don't know if you already new about that. But perhaps I should give an example, if I have the text below, with the two columns under fh in the top line highlighted, so the 6th and 7th character in each line highlighted:

sdasdfhafdlhasdf
dsfhalshdflkashf

adfhalasdfhasdfl
asdfhaldfhlsadhf

sahdflakshfdl


then I use the command:

:'<,'>B s/l/m/g

I get the result:

sdasdfhafdlhasdf
dsfhamshdflkashf

adfhamasdfhasdfl
asdfhamdfhlsadhf

sahdfmakshfdl

as you would expect, all l's in these two columns have been changed to m's. Now I do the same but I want to be prompted:

:'<,'>B s/l/m/gc

but this time I get this result:

sdasdafdlhasdf
dsfhahdflkashf

adfhasdfhasdfl
asdfhdfhlsadhf

sahdfkshfdl
fh
ls

la
al

la

Thanks for the script though Charles, I look forward to using it.
Rob.

Reply via email to