ledger icon indicating copy to clipboard operation
ledger copied to clipboard

Feature request: Allow underscores in amounts

Open qjcg opened this issue 1 year ago • 3 comments

Allowing amounts to include underscores would be very helpful for readability.

2024-11-22 Joe's Very Expensive Coffee
  Expenses:Restaurants:Coffee   1000000     ; status quo, amount can be difficult to read at a glance 
  Assets:Bank:Checking

2024-11-23 Joe's Very Expensive Coffee
  Expenses:Restaurants:Coffee   1_000_000   ; amount is more readable
  Assets:Bank:Checking

See:

qjcg avatar Nov 23 '24 12:11 qjcg

@qjcg Supporting this would make everything incompatible with regular ledger files and other programs. I'd argue against this. Perhaps supporting commas or decimals as per international money standards might make sense but this would break the ledger plain-text format, I believe.

wakatara avatar Nov 24 '24 16:11 wakatara

@qjcg Supporting this would make everything incompatible with regular ledger files and other programs. I'd argue against this. Perhaps supporting commas or decimals as per international money standards might make sense but this would break the ledger plain-text format, I believe.

@wakatara I'm with you on wanting to keep the format compatible with other ledger-related tools. To support that, commands like ledger print could remove underscores (or provide a flag that does).

On the pro side here is all of the prior art across programming languages (e.g. Go, Rust, Python, many others linked above) and markup languages (e.g. TOML). It's a very popular approach where numeric values need to be maximally readable at a glance in text-based formats.

qjcg avatar Nov 24 '24 19:11 qjcg

This is an interesting idea.

I took a look at the original ledger, and it doesn't look like it's supported, and it doesn't appear anyone has asked for it.

hledger did have an issue opened, but the devs decided against it.

Not sure what I want to do. I'll think about it.

howeyc avatar Nov 25 '24 20:11 howeyc