@@ -30,7 +30,12 @@ TIPS *ledger-tips*
30
30
31
31
Tips and useful commands
32
32
33
- * Try account-completion (as explained below)
33
+ * Try account-completion (as explained below). If you use YouCompleteMe, you
34
+ should disable it for Ledger files. Put this in your .vimrc:
35
+
36
+ if exists('g:ycm_filetype_blacklist')
37
+ call extend(g:ycm_filetype_blacklist, { 'ledger' : 1 })
38
+ endif
34
39
35
40
* You may use `:make ` for syntax checking. It may be convenient to define a
36
41
mapping for the following command:
@@ -77,12 +82,9 @@ Tips and useful commands
77
82
The decimal separator can be set using `g: ledger_decimal_sep ` . The default
78
83
value of `g: ledger_decimal_sep ` is `' .' ` .
79
84
80
- It is convenient to remap the command, for example to `<Leader> a ` :
81
-
82
- au FileType ledger vnoremap <silent><buffer> <Leader> a \
83
- :LedgerAlign<CR>
85
+ See below for the recommended mappings.
84
86
85
- * :call ledger#align_amount_at_cursor()
87
+ * ` :call ledger#align_amount_at_cursor()`
86
88
87
89
aligns the amount under the cursor and append/prepend the default currency.
88
90
The default currency can be set using `g: ledger_default_commodity ` . Whether
@@ -91,13 +93,31 @@ Tips and useful commands
91
93
value is 1). A separator between the commodity and the amount may be set
92
94
using `g: ledger_commodity_sep ` .
93
95
94
- It is convenient to define a mapping like the following:
96
+ See below for the recommended mappings.
97
+
98
+ * `:call ledger#autocomplete_and_align()`
99
+
100
+ when the cursor is on a number or immediately after it, invokes
101
+ `ledger#align_amount_at_cursor ()` to align it and add the default currency;
102
+ otherwise, performs autocompletion. If you define the following mappings in
103
+ your `.vimrc` then you may perform both autocompletion and alignment using
104
+ the <Tab> key:
105
+
106
+ au FileType ledger inoremap <silent> <Tab> \
107
+ <C-r> =ledger#autocomplete_and_align()<CR>
108
+ au FileType ledger vnoremap <silent> <Tab> :LedgerAlign<CR>
109
+
110
+ Alternatively, you may create a file `.vim /after/ ftplugin/ledger.vim `
111
+ containing the following definitions:
95
112
96
- au FileType ledger inoremap <silent><buffer> <C-l> \
97
- <Esc> :call ledger#align_amount_at_cursor()<CR>
113
+ inoremap <silent> <buffer> <Tab> \
114
+ <C-r> =ledger#autocomplete_and_align()<CR>
115
+ vnoremap <silent> <buffer> <Tab> :LedgerAlign<CR>
98
116
99
- Now, you may type `123.45 <C-l> ` , and have `$123 .45 ` properly aligned (assuming
100
- your default commodity is set to `' $' ` ).
117
+ Now, you may type `asset:check<Tab><Space> 123.45 <Tab> ` , and have the
118
+ account name autocompleted and `$123 .45 ` properly aligned (assuming your
119
+ default commodity is set to `' $' ` ). Or you may press <Tab> in Visual mode
120
+ to align a number of transactions at once.
101
121
102
122
* `:call ledger#entry()`
103
123
0 commit comments