Adding a single space to 'isk' but not multiple spaces?

27 views
Skip to first unread message

Tim Chase

unread,
Jan 2, 2025, 2:12:20 PMJan 2
to Vim Users
Using ledger(1) for finances, fields are usually delimited by runs
of 2+ spaces (or a tab), allowing a single space in the account-name.
So I might have a transaction like

2024-012-31 ! Groceries
Expenses:Household:Groceries:Food Lion $18.43
Liabilities:Credit Card:Visa -$18.43

(note the 2+ space indent and the 2+ space separation between the
account and the amount, while the single space in "Food Lion" and
"Credit Card")

It would be awfully handy to have colons and single-spaces be part
of 'isk' so that i_CTRL-N and i_CTRL-P can find full accounts (even
if they contain the occasional space), but that starts causing weird
issues (Vim really doesn't like having space in 'isk')

I've tried i_CTRL-X_CTRL-L to do whole-line completion but I have
enough transactions (and each amount regularly differs) that this
returns dozens or hundreds of matching lines, so it's less than useful.

Short of completely hijacking ^N/^P functionality to complete from
my known chart of accounts, is there a better solution I've overlooked?

Thanks!

-tim

(1) https://ledger-cli.org/



Enno

unread,
Jan 2, 2025, 3:47:57 PMJan 2
to vim_use
The option that you seem to exclude is setlocal complete+=k{dict} for a dict file of your accounts.
How about redefining :help 'define'/'include', or ~/.ctags suitably to detect and complete them by `i_ctrl-x_ctrl-d/i/] ?

Lifepillar

unread,
Jan 2, 2025, 4:16:44 PMJan 2
to vim...@googlegroups.com
On 2025-01-02, Tim Chase <v...@tim.thechases.com> wrote:
> Using ledger(1) for finances, fields are usually delimited by runs
> of 2+ spaces (or a tab), allowing a single space in the account-name.
> So I might have a transaction like
>
> 2024-012-31 ! Groceries
> Expenses:Household:Groceries:Food Lion $18.43
> Liabilities:Credit Card:Visa -$18.43
>
> (note the 2+ space indent and the 2+ space separation between the
> account and the amount, while the single space in "Food Lion" and
> "Credit Card")
>
> It would be awfully handy to have colons and single-spaces be part
> of 'isk' so that i_CTRL-N and i_CTRL-P can find full accounts
> is there a better solution I've overlooked?

Do you know about https://github.com/ledger/vim-ledger? Even if you
don't want a plugin, you may still copy its LedgerComplete omnifunc
function. I'm not using it currently, but I wrote the initial version of
it, and unless something was changed, it should allow you to complete
accounts by specifying prefixes. So, for instance, Ex:F:G<tab> becomes
Expenses:Food:Groceries. Very handy.

Btw, I have a bunch of mappings for several reports. They may not be up
to date, but in case you're interested:

https://github.com/lifepillar/vimrc/blob/master/after/ftplugin/ledger.vim

Hope this helps,
Life


Reply all
Reply to author
Forward
0 new messages