Last active
August 29, 2015 13:57
-
-
Save PeterRincker/9773667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Set b:formatprg to emulate a setlocal for formatprg | |
if exists('g:loaded_gq') || &cp || v:version < 700 | |
finish | |
endif | |
let g:loaded_gq = 1 | |
function! s:gq(type, ...) | |
let formatprg = &formatprg | |
let &formatprg = get(b:, 'formatprg', &formatprg) | |
try | |
if a:0 | |
execute "normal! '<V'>gq" | |
else | |
execute "normal! '[gq']" | |
endif | |
finally | |
let &formatprg = formatprg | |
endtry | |
endfunction | |
nnoremap <silent> <Plug>(gq) :<c-u>set opfunc=<SID>gq<cr>g@ | |
nnoremap <silent> <Plug>(gq-line) :<c-u>set opfunc=<SID>gq<bar>exe 'norm! '.v:count.'g@_'<cr> | |
xnoremap <silent> <Plug>(gq) :<c-u>call <SID>gq(visualmode(), 1)<cr> | |
nmap gq <Plug>(gq) | |
nmap gqq <Plug>(gq-line) | |
nmap gqgq <Plug>(gq-line) | |
xmap gq <Plug>(gq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment