samedi 18 avril 2015

vim search regular expression replace with register

I'd like to search a regex pattern with vim and replace the matches with a paste from a register. In detail that means:



acb123acb
asokqwdad
def442ads
asduiosdf
df567hjk


should finish with



acbXYZacb
asokqwdad
defPOWads
asduiosdf
dafMANhjk


where I had



XYZ
POW
MAN


in a register A (:g/pattern/y A)


A regex pattern to search for might be [0-9]{3} to match the 3 numbers from the text block.


Block mode would help if there were no lines between the matches...


I could use a perl script therefore of course. However I'm sure, if possible in vim it were a lot faster, right?


Thank you in advance


Aucun commentaire:

Enregistrer un commentaire