Code Monkey home page Code Monkey logo

evil-ledger's Introduction

Making ledger-mode more Evil

MELPA

The evil-ledger package provides a minor mode for Emacs that adds Evil motions and operators to ledger-mode buffers. It allows you to treat transactions as text objects while in evil-mode -- selecting, deleting, and changing around and inside them as a unit.

For example, given the transaction and cursor (indicated by |) below

2000/01/01 * Landlord
    Expenses:Rent      |                     $500.00
    Assets::Chequing

vax selects the transaction around point and all whitespace up to the next transaction. This makes for easy copying, moving, and deletion of transactions as a whole, instead of by selecting a series of lines.

Installation

evil-ledger is available from MELPA.

Usage

evil-ledger-mode is a self-contained minor mode, so you can simply enable it in a ledger-mode buffer to try it out, and disable it when you don't need it.

Using Transactions as Text Objects

evil-ledger-mode adds ix and ax to the visual and operator states for selecting inside and around transactions, respectively. This means you can, for example

  • Select the transaction at point with vix, and include surrounding whitespace with vax.
  • Delete the current transaction with dax, or replace it with cax.

evil-ledger-mode supports repeated invocations, so for example vaxax selects the transaction at point, plus the next one as well, and so on.

Commands also support numerical prefixes, so d3ax deletes the current and next two transactions.

Navigation

evil-ledger-mode also provides navigation aids gj and gk for jumping to the next and previous transactions, respectively. Of course, 3gj will work as expected.

Alignment and Sorting

evil-ledger-mode adds an evil-ledger-align operator to visual state with the keybinding =, so that, for example, v3ax= will select the next three transactions and align all postings in them.

There is also an evil-ledger-sort operator that will sort transactions by date (as per ledger-sort-region), although it does not have a keybinding by default. You can add one with

(evil-define-key* 'visual evil-ledger-mode-map
                  "S" #'evil-ledger-sort)

or by setting evil-ledger-sort-key.

Configuration

To make the minor mode start automatically in Ledger buffers, you can add it as a hook in your configuration, e.g.

(add-hook 'ledger-mode-hook #'evil-ledger-mode))

For use-package users, the following is a sample configuration:

(use-package evil-ledger
  :ensure t
  :after ledger-mode
  :config
  (setq evil-ledger-sort-key "S")
  (add-hook 'ledger-mode-hook #'evil-ledger-mode))

License

All code is made available under the GPLv3, the same license as Emacs itself.

evil-ledger's People

Contributors

atheriel avatar syl20bnr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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