Generic operator function with interactive mode

This commit is contained in:
Junegunn Choi
2013-11-30 11:41:11 +09:00
parent 3921d0bab3
commit 462a800064

View File

@@ -294,6 +294,19 @@ since the same can be easily done using the negative N-th parameter: `<Enter>-=`
You can define an operator function which executes EasyAlign command, so that it You can define an operator function which executes EasyAlign command, so that it
can be used with a Vim movement. can be used with a Vim movement.
```vim
function! s:easy_align_op(type, ...)
'[,']EasyAlign
endfunction
nnoremap <Leader>a :set opfunc=<SID>easy_align_op<Enter>g@
```
Now without going into visual mode, you can align the lines in the paragraph by
`<Leader>aip=` or `<Leader>aip:`.
Or you can be more specific as follows, so you can do `<Leader>=ip` or
`<Leader>:ip`.
```vim ```vim
function! s:easy_align_1st_eq(type, ...) function! s:easy_align_1st_eq(type, ...)
'[,']EasyAlign= '[,']EasyAlign=
@@ -306,9 +319,6 @@ endfunction
nnoremap <Leader>: :set opfunc=<SID>easy_align_1st_colon<Enter>g@ nnoremap <Leader>: :set opfunc=<SID>easy_align_1st_colon<Enter>g@
``` ```
Now without going into visual mode, you can align the lines in the paragraph
by `<Leader>=ip` or `<Leader>:ip`.
Alignment options Alignment options
----------------- -----------------