Home

Awesome

vim-ledger

Vint Vader

Filetype detection, syntax highlighting, auto-formatting, auto-completion, and other tools for working with ledger files. Compatible with both ledger and hledger. See plaintextaccounting.org for background information and other useful links.

Usage

Install as you would any other VIM plugin. There are a variety of ways depending on your plugin manager. For example with Pathogen you would clone this repository into your configuration directory. With vim-plug and many similar ones, you would declare it in your rc file like this, then run :PlugInstall:

Plug 'ledger/vim-ledger'

Install using VIM packages functionality (vim 8+)

To install as a single plugin, using VIM packages functionality first create a target folder:

mkdir -p ~/.vim/pack/ledger/start
cd ~/.vim/pack/ledger/start
git clone <URL>

Edit .vimrc and append the line:

set loadplugins

You can also manually copy the corresponding directories into your VIM plugins directory.

One installed this plugin will identify files ending with .ldg, .ledger, or .journal as ledger files automatically. Alternatively if you use a different extension you can add a modeline to each like this:

; vim: filetype=ledger

Tips and useful commands

Configuration

Include the following let-statements somewhere in your .vimrc to modify the behaviour of the ledger filetype.

Completion

Omni completion is implemented for transactions descriptions and posting account names.

Accounts

By default, account names are matched by the start of every sub-level. When you insert an account name like this:

Asse<C-X><C-O>

You will get a list of top-level accounts that start like this.

Go ahead and try something like:

As:Ban:Che<C-X><C-O>

When you have an account like this, 'Assets:Bank:Checking' should show up.

If fuzzy matching based account completion is enabled, the matches are loaded based on string similarity and without regard for the sub-levels.

In the previous example, with fuzzy matching enabled, you could load up matches by doing something like:

Chec<C-X><C-O>

Notice that we did not need to write the initial account components.

When you want to complete on a virtual transaction, it's currently best to keep the cursor in front of the closing bracket. Of course you can insert the closing bracket after calling the completion, too.

License

Copyright 2019–2021 Caleb Maclennan
Copyright 2009–2017 Johann Klähn
Copyright 2009 Stefan Karrmann
Copyright 2005 Wolfgang Oertl

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.