Giter VIP home page Giter VIP logo

vim-ledger's Introduction

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'

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. Alaternatively if you use a different extension you can add a modeline to each like this:

; vim: filetype=ledger

Tips and useful commands

  • Try account-completion (as explained below)

  • :call ledger#transaction_date_set(line('.'), 'auxiliary')

    will set today's date as the auxiliary date of the current transaction. You can use also primary or unshift in place of auxiliary. When you pass "unshift" the old primary date will be set as the auxiliary date and today's date will be set as the new primary date. To use a different date pass a date measured in seconds since 1st Jan 1970 as the third argument.

  • :call ledger#transaction_state_set(line('.'), '*')

    sets the state of the current transaction to '*'. You can use this in custom mappings.

  • :call ledger#transaction_state_toggle(line('.'), ' *?!')

    will toggle through the provided transaction states. You can map this to double-clicking for example:

      noremap <silent><buffer> <2-LeftMouse>\
      :call ledger#transaction_state_toggle(line('.'), ' *?!')<CR>
    
  • Align commodities at the decimal point. See help ledger-tips.

  • :call ledger#entry()

    will replace the text on the current line with a new transaction based on the replaced text.

Configuration

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

  • Number of columns that will be used to display the foldtext. Set this when you think that the amount is too far off to the right.

      let g:ledger_maxwidth = 80
    
  • String that will be used to fill the space between account name and amount in the foldtext. Set this to get some kind of lines or visual aid.

      let g:ledger_fillstring = '    -'
    
  • If you want the account completion to be sorted by level of detail/depth instead of alphabetical, include the following line:

      let g:ledger_detailed_first = 1
    
  • By default vim will fold ledger transactions, leaving surrounding blank lines unfolded. You can use g:ledger_fold_blanks to hide blank lines following a transaction.

      let g:ledger_fold_blanks = 0
    

    A value of 0 will disable folding of blank lines, 1 will allow folding of a single blank line between transactions; any larger value will enable folding undconditionally.

    Note that only lines containing no trailing spaces are considered for folding. You can take advantage of this to disable this feature on a case-by-case basis.

Completion

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

Accounts

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.

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/.

vim-ledger's People

Contributors

kljohann avatar alerque avatar tlvince avatar rohieb avatar abobov avatar kcwu avatar rcaputo avatar ajgrf avatar chadvoegele avatar edwardbetts avatar gregorias avatar kanreki avatar yhlfh avatar ropery avatar cypok avatar ustuehler avatar parmort avatar lifepillar avatar jwiegley avatar entropitor avatar zannalov avatar jamielinux avatar engines-wafu avatar aquilax avatar enderw88 avatar cgiacofei avatar sudoforge avatar artkpv avatar andyleejordan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.