Block-wise visual wrapping works with limitations.

This commit is contained in:
Israel Chauca Fuentes
2010-06-09 03:20:11 -05:00
parent 6d1cc1187b
commit d1621b6672
3 changed files with 19 additions and 18 deletions
+1
View File
@@ -1,4 +1,5 @@
*.sw? *.sw?
*.un?
*.vba *.vba
*.zip *.zip
*.gz *.gz
+16 -18
View File
@@ -186,27 +186,12 @@ function! delimitMate#IsBlockVisual() " {{{
endfunction " }}} endfunction " }}}
function! delimitMate#Visual(del) " {{{ function! delimitMate#Visual(del) " {{{
let mode = mode()
if mode == "\<C-V>"
redraw
echom "delimitMate: delimitMate is disabled on blockwise visual mode."
return ""
endif
" Store unnamed register values for later use in delimitMate#RestoreRegister().
let b:save_reg = getreg('"')
let b:save_reg_mode = getregtype('"')
if len(getline('.')) == 0 if len(getline('.')) == 0
" This for proper wrap of empty lines. " This for proper wrap of empty lines.
let @" = "\n" let @" = "\n"
endif endif
if mode ==# "V" " Let's find which kind of delimiter we got:
let dchar = "\<BS>"
else
let dchar = ""
endif
let index = index(b:delimitMate_left_delims, a:del) let index = index(b:delimitMate_left_delims, a:del)
if index >= 0 if index >= 0
let ld = a:del let ld = a:del
@@ -219,12 +204,25 @@ function! delimitMate#Visual(del) " {{{
let rd = a:del let rd = a:del
endif endif
let index = index(b:delimitMate_quotes_list, a:del) if index(b:delimitMate_quotes_list, a:del) >= 0
if index >= 0
let ld = a:del let ld = a:del
let rd = ld let rd = ld
endif endif
let mode = mode()
if mode == "\<C-V>"
" Block-wise visual
return "I" . ld . "\<Esc>gv\<Right>A" . rd . "\<Esc>"
elseif mode ==# "V"
let dchar = "\<BS>"
else
let dchar = ""
endif
" Store unnamed register values for later use in delimitMate#RestoreRegister().
let b:save_reg = getreg('"')
let b:save_reg_mode = getregtype('"')
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>" return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
endfunction " }}} endfunction " }}}
+2
View File
@@ -562,6 +562,8 @@ This script was inspired by the auto-completion of delimiters on TextMate.
|---------|------------|-----------------------------------------------------| |---------|------------|-----------------------------------------------------|
2.4DEV 2010-06-06 * Current release: 2.4DEV 2010-06-06 * Current release:
- Unbalanced parens: see :help delimitMateBalance. - Unbalanced parens: see :help delimitMateBalance.
- Visual wrapping now works on block-wise visual
with some limitations.
|---------|------------|-----------------------------------------------------| |---------|------------|-----------------------------------------------------|
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space> 2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>