On 12-Nov-09 10:45:02, nev young wrote:
(Ted Harding) wrote:
Interesting thread! Now that it looks as though vim is romping home in its rightful place at the head of the field, let me ask advocates of other editors how they would achieve the following editing task.
You have a long document, in which are lots of occurrences of numbers which have the Contintental separator system ("." to separate thousands, "," for the decimal point). So, for instance, one million Francs and 25 Centimes is 1.000.000,25
Now run a global edit to convert these into the Real Thing, so that the above example becomes 1,000,000.25 for instance.
<untested and from memory> for vi / vim
:1,$s/([0-9]).([0-9])/\1~#~\2/g :1,$s/([0-9]),([0-9])/\1.\2/g :1,$s/~#~/,/g
That's basically exactly it -- except don't use "~#~" for the first replacement (since "~" is special). I assume you wanted to plant a pattern which would very probably be unique to its context (rather than simply "#"), in view of your last line.
So you should use something like
:1,$s/([0-9]).([0-9])/\1@#@\2/g :1,$s/([0-9]),([0-9])/\1.\2/g :1,$s/@#@/,/g
for kate (check reg exp & use place holders) [ctrl]+R <find string>([0-9]),([0-9]) <replace string> \1~#~\2 [ctrl]+R <find string>([0-9]).([0-9]) <replace string> \1,\2 [ctrl]+R <find string>~#~ <replace string> .
easy.
nev
Easy yes -- and just as easy in vim!
Regarding Mark Rogers' point about column editing: vim has that too in a very adaptable form: First select a column (or a bank of adjacent columns) with Ctrl-V followed by curesor movements. However, be careful about ":" editing commands, since all the rows in which any column has been highlighted are considered as a row-range for ":".
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 12-Nov-09 Time: 11:14:30 ------------------------------ XFMail ------------------------------