aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-23 14:45:17 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-23 14:45:17 +1200
commit9a9f02405fee72a442bcd48fc0d9227727bb79ec (patch)
treed646e01a940ebc316c053b2b777e2d809cd19bef
parentde977486005f37bf102349cf13ac343582016b40 (diff)
downloaddotfiles-9a9f02405fee72a442bcd48fc0d9227727bb79ec.tar.gz
Make space appending for quote indent configurable
-rw-r--r--vim/autoload/quote.vim15
1 files changed, 9 insertions, 6 deletions
diff --git a/vim/autoload/quote.vim b/vim/autoload/quote.vim
index b519e717..616fd307 100644
--- a/vim/autoload/quote.vim
+++ b/vim/autoload/quote.vim
@@ -9,8 +9,9 @@ endfunction
" Quoting operator function
function! quote#QuoteOpfunc(type) abort
- " May as well make this configurable
+ " Make character and space appending configurable
let char = get(b:, 'quote_char', '>')
+ let space = get(b:, 'quote_space', 1)
" Iterate over each matched line
for li in range(line('''['), line(''']'))
@@ -23,11 +24,13 @@ function! quote#QuoteOpfunc(type) abort
continue
endif
- " Only add a space after the quote character if this line isn't already
- " quoted with the same character
- let new = cur[0] == char
- \ ? char.cur
- \ : char.' '.cur
+ " If configured to do so, add a a space after the quote character, but
+ " only if this line isn't already quoted
+ let new = char
+ if l:space && cur[0] != char
+ let new .= ' '
+ endif
+ let new .= cur
call setline(li, new)
endfor