I have a huge file that has multiple columns as shown below:
J02-31 23.2 ...
J30-09 -45.4 ...
J05+30 56.1 ...
J00-20 -78.2 ...
J11-54 232.0 ...
... ... ...
I would like to replace - with $-$ only in the first column, i.e., my output should be like this:
J02$-$31 23.2 ...
J30$-$09 -45.4 ...
J05+30 56.1 ...
J00$-$20 -78.2 ...
J11$-$54 232.0 ...
... ... ...
Is there a way to do this using vi. I know that python/pandas can do it, but I am interested in vi usage.
%s/oldstring/newstring/gfor replacement.:%s/-/$-$would do-sign in the second column. Both the answers below are helpful actually.g(global command) would change it everywhere. Omitting it just changes the first column, but the only caveat is that it also ends up changing every-in the last row.