My lines look like this:
a;b;c;d
e;f;g;h
i;j;k;l;m;n;o;p
What i want is this:
a;b;c;-d
e;f;g;-h
i;j;k;l;m;n;o;-p
I want to add a minus after the last appearance of a semicolon. Any help is appreciated, thanks.
^.+;\K.+$
-$0
. matches newline
Explanation:
^ : beginning of line
.+ : 1 or more any character but newline, greedy
; : a semicolon
\K : forget all we have seen until this position
.+ : 1 or more any character but newline
$ : end of line
Replacement:
- : a dash
$0 : the whole match
Result for given example:
a;b;c;-d
e;f;g;-h
i;j;k;l;m;n;o;-p
;
and then press HOME
. Now start recording macro
. Press END
, SHIFT + F3
(to search last ;
). Press Right arrow
and type -
. Press DOWN
and HOME
. Now, stop recording and run macro till end of file. It looks dirty but hardly takes few seconds.