Mun Johl typed (on Fri, Jun 30, 2006 at 03:43:34PM -0700):
| Hi,
| 
| When in vim, I often want to format numbers.  For example, when editing
| a Verilog file, I want to quickly change 12345678 to 12_345_678 for
| readability; and when editing an email, sometimes I'd like to change
| 12345678 to 12,345,678 .
| 
| I did a search for programs to format numbers, but didn't really find
| anything suitable.  Before I take on the task myself, I thought I'd ask
| if anyone knows of any such program/script/plugin.

I have some accounting programs with give me large dollar&cents amounts;
I use sed to prettify them by adding commas.

Play with this:

echo '    123456789876543.21' |
sed '
: C
/[0-9][0-9][0-9][0-9][,.]/s/ \([-+0-9]*[0-9]\)\([0-9][0-9][0-9][,.]\)/\1,\2/g
t C
'

-- 
JP
        ==> http://www.frappr.com/cusm <==

Reply via email to