diff options
author | teoric <code.teoric@gmail.com> | 2017-01-28 16:46:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-28 16:46:48 +0100 |
commit | 8315f1483397e327603c8e31e4849a39adac6faf (patch) | |
tree | 79bb3a7a0cc363764a65c8664396d32e02cbdd95 /plugins | |
parent | b64e702bc4c83d33247ef9dc966cb83fd72b3011 (diff) | |
download | yapf-8315f1483397e327603c8e31e4849a39adac6faf.tar.gz |
Suggestion: VIM command
I do not use YAPF so often, so I do not want a mapping. But calling the function is unhandy, too. Therefore I created a VIM command `:YAPF` that can take a range (see comments in code for how to use it).
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/yapf.vim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/yapf.vim b/plugins/yapf.vim index 24b3510..82f9991 100644 --- a/plugins/yapf.vim +++ b/plugins/yapf.vim @@ -20,6 +20,13 @@ " map <C-P> :call yapf#YAPF()<cr> " imap <C-P> <c-o>:call yapf#YAPF()<cr> " +" Alternatively, you can call the command YAPF. If you omit the range, +" it will reformat the whole buffer. +" +" example: +" :YAPF " formats whole buffer +" :'<,'>YAPF " formats lines selected in visual mode +" function! yapf#YAPF() range " Determine range to format. let l:line_ranges = a:firstline . '-' . a:lastline @@ -35,3 +42,5 @@ function! yapf#YAPF() range " Reset cursor to first line of the formatted range. call cursor(a:firstline, 1) endfunction + +command! -range=% YAPF <line1>,<line2>call yapf#YAPF() |