I am trying to do a search and replace in vim (rather, gvim) and keep getting stuck up trying to separate words.
I need to convert something like this:
(COND <ASEL&~ASELb|XOR|~XORb> (
To this:
(COND ASEL=1'b1 && ASELb=1'b0 || XOR=1'b1 || XORb=1'b1 (
Basically, every occurrence of these 'words' has to be changed this way:
~ABC --> ABC=1'b0
ABC --> ABC=1'b1
I have tried something like this to do it but can't get the pattern to match:
s/\([<&|]\)\~\([^<&|]\)\([>&|]\)/\1\2==1'b0\3
s/\([<&|]\)\([^<&|=]+\)\([>&|]\)/\1\2==1'b1\3
The idea behind this was to do one 'word' at a time by separating it out in \2 above and then printing \1 and \3 as is with \2=1'b0 or \2=1'b1.
And then take care of the rest, like '&' going to '&&', removing the '<..>' at the ends in the subsequent commands.
What am I doing wrong here? Is there a better way to go about this?