tags:

views:

59

answers:

2

I have a one liner in vim which I regularly use for find and replace.

I now want to use it to remove tags - something like this but I looks like I need to escape the / I'm not sure what am I missing.

:%s~<Validator>*</Validator>~~g
+1  A: 
:%s~<Validator>.*</Validator>~~g

Does the trick

wmitchell
A: 

use awk.

awk -vRS="</Validator>"  '{gsub(/<Validator>.*/,"") }1' file

The above removes from tag to tag, even if they span multiple lines.

ghostdog74
if sed is mentioned in the tag, i don't see why awk cannot be used.
ghostdog74
can you use AWK within VIM in the same we I am using SED ??
wmitchell
@imerez: You're not using sed; you're using vim's builtin :s[ubstitute] command.
Roger Pate
ahh thanks Roger - good to know !
wmitchell