reddit / emacs

Add Grouping Commas to Numbers in Emacs

lstrang · 2022-06-01 12:24
I wrote `commify` several years ago, but have never done anything to announce it. Just did some minor tweaking, so I thought I would let reddit-ers know. It's a pretty simple package, but I use it all the time. It inserts grouping commas into a number near the cursor, or all numbers in a region. If invoked on a number that already has grouping commas, it removes them. So, it toggles the commas on and off. It tries to avoid things that you don't want commas on, such as dates, or numbers with leading, or identifiers. It can also work with hex, octal, and binary numbers, each with their own grouping character, normally, '_'. I have it bound to the keychord ',,' which makes it easy to invoke and remember. It's on MELPA, so give it a try.
northcode · 2022-06-01 17:23
So does it actually modify the buffer or is it just virtual ones as a visual aid?
_viz_ · 2022-06-01 17:37
It would be interesting to see a package that supports the Indian numeral system https://en.wikipedia.org/wiki/Indian_numbering_system. Maybe I should just stop being lazy and look into implementing it myself.
lstrang · 2022-06-01 21:54
It actually modifies the buffer.
HM0880 · 2022-06-02 00:59
Very nice. I work with large integers enough that this is useful to me. Thanks for sharing.
HM0880 · 2022-06-02 01:04
Link: https://github.com/ddoherty03/commify
onetom · 2022-06-02 08:12
great little package! btw, do key-chords work reliably on terminal Emacs, over SSH? Since their operation depends on timing, I would suspect they might be unreliable over higher latency connections.
Phil-Hudson · 2022-06-03 13:45
Good question. Ask it in its own post.