I would like to use Vim to match a regular expression and perform a substitution. I have a tsv file with lines that look like this:
rs11223-A -A
rs23300-G -TTA
rs9733-T -G
rs11900000-GT -TTG
I wish to substitute the dash (-) character for a tab only in the first column after the rs…
In Vim I was attempting to perform the substitution using:
:%s/(?<=^rs[0-9]{1,12})-/\t/g
Could anyone point out what my problem is and a correct solution?
It may be dependent on configuration, but in my environment I have to prepend
{ , }with\.Also, Vim has
\zsand\zeto start and end matching, so you usually don’t have to deal with normal regex lookaround.This does what you want: