aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-16 13:46:10 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-16 13:46:10 +1200
commit009b0efd84118d4ce3ffcf2fdc400477326f4f30 (patch)
tree63d5affd378d7a6ba646d1bb1fdd78555f3796e8
parent5a88a073fb2a1efeef8363b878f5582b3bd9997a (diff)
downloaddotfiles-009b0efd84118d4ce3ffcf2fdc400477326f4f30.tar.gz
dotfiles-009b0efd84118d4ce3ffcf2fdc400477326f4f30.zip
Add reformatting analogue to quote mappings
-rw-r--r--vim/after/ftplugin/gitcommit.vim6
-rw-r--r--vim/after/ftplugin/mail.vim6
-rw-r--r--vim/after/ftplugin/markdown.vim6
-rw-r--r--vim/autoload/quote.vim12
4 files changed, 30 insertions, 0 deletions
diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim
index 7fab5a92..5699188d 100644
--- a/vim/after/ftplugin/gitcommit.vim
+++ b/vim/after/ftplugin/gitcommit.vim
@@ -27,6 +27,12 @@ endif
nnoremap <buffer> <expr> <LocalLeader>q quote#Quote()
nnoremap <buffer> <expr> <LocalLeader>qq quote#Quote().'_'
xnoremap <buffer> <expr> <LocalLeader>q quote#Quote()
+nnoremap <buffer> <expr> <LocalLeader>Q quote#QuoteReformat()
+nnoremap <buffer> <expr> <LocalLeader>QQ quote#QuoteReformat().'_'
+xnoremap <buffer> <expr> <LocalLeader>Q quote#QuoteReformat()
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q'
\ . '|nunmap <buffer> <LocalLeader>qq'
\ . '|xunmap <buffer> <LocalLeader>q'
+ \ . '|nunmap <buffer> <LocalLeader>Q'
+ \ . '|nunmap <buffer> <LocalLeader>QQ'
+ \ . '|xunmap <buffer> <LocalLeader>Q'
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 3e3a08c5..4d2f0a17 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -24,6 +24,12 @@ endif
nnoremap <buffer> <expr> <LocalLeader>q quote#Quote()
nnoremap <buffer> <expr> <LocalLeader>qq quote#Quote().'_'
xnoremap <buffer> <expr> <LocalLeader>q quote#Quote()
+nnoremap <buffer> <expr> <LocalLeader>Q quote#QuoteReformat()
+nnoremap <buffer> <expr> <LocalLeader>QQ quote#QuoteReformat().'_'
+xnoremap <buffer> <expr> <LocalLeader>Q quote#QuoteReformat()
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q'
\ . '|nunmap <buffer> <LocalLeader>qq'
\ . '|xunmap <buffer> <LocalLeader>q'
+ \ . '|nunmap <buffer> <LocalLeader>Q'
+ \ . '|nunmap <buffer> <LocalLeader>QQ'
+ \ . '|xunmap <buffer> <LocalLeader>Q'
diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim
index 38f2a8b9..a5c80ca9 100644
--- a/vim/after/ftplugin/markdown.vim
+++ b/vim/after/ftplugin/markdown.vim
@@ -30,6 +30,12 @@ endif
nnoremap <buffer> <expr> <LocalLeader>q quote#Quote()
nnoremap <buffer> <expr> <LocalLeader>qq quote#Quote().'_'
xnoremap <buffer> <expr> <LocalLeader>q quote#Quote()
+nnoremap <buffer> <expr> <LocalLeader>Q quote#QuoteReformat()
+nnoremap <buffer> <expr> <LocalLeader>QQ quote#QuoteReformat().'_'
+xnoremap <buffer> <expr> <LocalLeader>Q quote#QuoteReformat()
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q'
\ . '|nunmap <buffer> <LocalLeader>qq'
\ . '|xunmap <buffer> <LocalLeader>q'
+ \ . '|nunmap <buffer> <LocalLeader>Q'
+ \ . '|nunmap <buffer> <LocalLeader>QQ'
+ \ . '|xunmap <buffer> <LocalLeader>Q'
diff --git a/vim/autoload/quote.vim b/vim/autoload/quote.vim
index 6e943091..26e95698 100644
--- a/vim/autoload/quote.vim
+++ b/vim/autoload/quote.vim
@@ -28,3 +28,15 @@ function! quote#QuoteOpfunc(type) abort
endfor
endfunction
+
+" Tack on reformatting the edited text afterwards
+function! quote#QuoteReformat() abort
+ set operatorfunc=quote#QuoteReformatOpfunc
+ return 'g@'
+endfunction
+
+" Wrapper operator function to reformat quoted text afterwards
+function! quote#QuoteReformatOpfunc(type) abort
+ call quote#QuoteOpfunc(a:type)
+ normal! '[gq']
+endfunction