Skip to content

Commit 7cb3e66

Browse files
authored
Merge pull request #53 from lifepillar/dont-align-on-1st-col
Do not align when number starts at first column.
2 parents 9850f4d + 69b138e commit 7cb3e66

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

autoload/ledger.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,12 @@ endf
501501
function! ledger#autocomplete_and_align()
502502
if pumvisible()
503503
return "\<c-n>"
504-
" See http://stackoverflow.com/questions/23323747/vim-vimscript-get-exact-character-under-the-cursor
505-
elseif matchstr(getline('.'), '\%' . (col('.')-1) . 'c.') =~ '\d'
504+
endif
505+
" Align an amount only if there is a digit immediately before the cursor and
506+
" such digit is preceded by at least one space (the latter condition is
507+
" necessary to avoid situations where a date starting at the first column is
508+
" confused with a commodity to be aligned).
509+
if match(getline('.'), '\s.*\d\%'.col('.').'c') > -1
506510
norm h
507511
call ledger#align_amount_at_cursor()
508512
return "\<c-o>A"

0 commit comments

Comments
 (0)