aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/quote.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-14 20:52:49 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-14 20:52:49 +1200
commit720b6971850e636912737fe9bcb72fb0d566f344 (patch)
tree4311fd0fbb3a936021de33172804e16bd72816ef /vim/autoload/quote.vim
parentMerge branch 'release/v1.29.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-3cf6d30492cf9bf3f91040b64b09c0ecb33df329.tar.gz (sig)
dotfiles-3cf6d30492cf9bf3f91040b64b09c0ecb33df329.zip
Merge branch 'release/v1.30.0'v1.30.0
* release/v1.30.0: Bump VERSION Revert "Remove :nohlsearch from vimrc" Spin off vimrc_reload_filetype.vim Add mail quote maps for gitcommit and markdown Expand and comment quoting functions Change mail quoting to generic autoload function Remove bell settings from .gvimrc
Diffstat (limited to 'vim/autoload/quote.vim')
-rw-r--r--vim/autoload/quote.vim30
1 files changed, 30 insertions, 0 deletions
diff --git a/vim/autoload/quote.vim b/vim/autoload/quote.vim
new file mode 100644
index 00000000..6e943091
--- /dev/null
+++ b/vim/autoload/quote.vim
@@ -0,0 +1,30 @@
+" Quote lines in mail and mail-based formats: Markdown, Git commits, etc
+
+" Operator function wrapper for the mapping to call
+function! quote#Quote() abort
+ set operatorfunc=quote#QuoteOpfunc
+ return 'g@'
+endfunction
+
+" Quoting operator function
+function! quote#QuoteOpfunc(type) abort
+
+ " May as well make this configurable
+ let l:char = exists('b:quote_char')
+ \ ? b:quote_char
+ \ : '>'
+
+ " Iterate over each matched line
+ for l:li in range(line('''['), line(''']'))
+
+ " Only add a space after the quote character if this line isn't already
+ " quoted with the same character
+ let l:cur = getline(l:li)
+ let l:new = stridx(l:cur, l:char) == 0
+ \ ? l:char.l:cur
+ \ : l:char.' '.l:cur
+ call setline(l:li, l:new)
+
+ endfor
+
+endfunction