Loading ...
Sorry, an error occurred while loading the content.

70975Re: Any programs to format numbers out there?

Expand Messages
  • Trent Gamblin
    Jun 30, 2006
    • 0 Attachment
      On Fri, 2006-06-30 at 15:43 -0700, Mun Johl wrote:
      > 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.
      >
      > Thanks in advance.
      >
      > Regards,

      You can use the regular expression:
      :%s/\(\d\)\(\(\d\d\d\)\+\d\@!\)\@=/\1,/g
      To add commas to all large numbers. Replace the comma with an underscore
      to add underscores instead.
    • Show all 4 messages in this topic