EasyAlign command as Vim operator

This commit is contained in:
Junegunn Choi
2013-10-10 12:51:43 +09:00
parent 438b5312ee
commit cdc648f5a4

View File

@@ -619,6 +619,26 @@ let g:easy_align_delimiters = {
\ } \ }
``` ```
### EasyAlign as Vim operator
You can define an operator function which calls EasyAlign command, so that it
can be used with a Vim movement.
```vim
function! s:easy_align_1st_eq(type, ...)
'[,']EasyAlign=
endfunction
nnoremap <Leader>= :set opfunc=<SID>easy_align_1st_eq<Enter>g@
function! s:easy_align_1st_colon(type, ...)
'[,']EasyAlign:
endfunction
nnoremap <Leader>: :set opfunc=<SID>easy_align_1st_colon<Enter>g@
```
Now without going into Visual mode, you can align text in the paragraph
by `<Leader>=ip` or `<Leader>:ip`.
Advanced examples and use cases Advanced examples and use cases
------------------------------- -------------------------------