Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions autoload/easy_align.vim
Original file line number Diff line number Diff line change
Expand Up @@ -677,25 +677,57 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, bvis)
let n = strpart(n, 0, len(n) - 1)
endif
elseif c == 13 " Enter key
" simon was here
" Accept the changes and exit. Same as <CTRL-P>
if s:live
if !empty(d)
let ch = d
break
else
let s:live = 0
endif
else
let s:live = 1
endif
" simon was here
" Cycle through the different alignments using letter 'a'.
elseif ch == 'a' || ch == 'A'
let mode = s:shift(a:modes, 1)
if has_key(opts, 'a')
let opts.a = mode . strpart(opts.a, 1)
endif
elseif ch == '-'
if empty(n) | let n = '-'
" simon was here
" Override the * option to align all columns.
elseif n == '*' | let n = '-'
elseif n == '**' | let n = '-'
" simon was here
" Override the numbers the user typed for single column aligning.
" Allows us to press - after we have already typed a number.
elseif ( n > '0' && n <= '9')
let n = '-'
elseif n == '-' | let n = ''
else | let check = 1
endif
elseif ch == '*'
if empty(n) | let n = '*'
elseif n == '*' | let n = '**'
elseif n == '**' | let n = ''
" simon was here
" Override the numbers the user typed for single column aligning
" Allows us to press * after we have already typed a number.
elseif ( n > '0' && n <= '9')
let n = ch
" simon was here
" Override if they aligned the last column
elseif n == '-' | let n = '*'
else | let check = 1
endif
elseif empty(d) && ((c == 48 && len(n) > 0) || c > 48 && c <= 57) " Numbers
if n[0] == '*' | let check = 1
else | let n = n . ch
end
" simon was here
" User typed a number to choose which column to align.
elseif ((c == 48 && len(n) > 0) || c > 48 && c <= 57)
let n = ch
elseif ch == "\<C-D>"
call s:shift_opts(opts, 'da', vals['delimiter_align'])
elseif ch == "\<C-I>"
Expand Down Expand Up @@ -754,7 +786,8 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, bvis)
else
silent! call remove(opts, 'a')
endif
elseif ch == "\<C-_>" || ch == "\<C-X>"
" simon was here - Enter regex using '/' key
elseif ch == "\<C-_>" || ch == "\<C-X>" || ch == '/'
if s:live && regx && !empty(d)
break
endif
Expand Down Expand Up @@ -1116,6 +1149,9 @@ function! s:align(bang, live, visualmode, first_line, last_line, expr)
if bypass_fold | let &l:foldmethod = 'manual' | endif

if empty(n) && empty(ch) || s:live
" simon was here
" Start live mode with 'align all columns' enabled by default
let n = '*'
let [mode, n, ch, opts, regexp] = s:interactive(range, copy(modes), n, ch, opts, rules, vis, bvis)
endif

Expand Down