40 Commits
2.5 ... 2.6

Author SHA1 Message Date
Israel Chauca Fuentes
860c45ab2a Limit autocmd effects. 2011-01-14 22:13:00 -06:00
Israel Chauca Fuentes
8686edfc63 Update version. 2011-01-14 20:59:53 -06:00
Israel Chauca Fuentes
5e7a7c4738 Update change log. 2011-01-14 20:57:56 -06:00
Israel Chauca Fuentes
928cc1146a Fix behaviour of b:loaded_delimitMate. 2011-01-14 20:49:28 -06:00
Israel Chauca Fuentes
d420afdacd Trivial formatting. 2011-01-14 20:37:40 -06:00
Israel Chauca Fuentes
f6015300a0 Modify smart_matchpairs regex. 2011-01-14 20:37:04 -06:00
Israel Chauca Fuentes
e183064744 Update change log. 2011-01-14 20:36:29 -06:00
Israel Chauca Fuentes
40849c94ef Update documentation. 2011-01-14 20:29:22 -06:00
Israel Chauca Fuentes
4c1424f9bd Reorder stuff. 2010-12-11 05:23:59 -06:00
Israel Chauca Fuentes
0783f97fc0 Modify :DelimitMateTest output. 2010-12-11 05:23:27 -06:00
Israel Chauca Fuentes
e551885c24 Prevent indenting from propagating on the report. 2010-12-11 00:16:31 -06:00
Israel Chauca Fuentes
4891a04258 Fix double space. 2010-12-11 00:10:21 -06:00
Israel Chauca Fuentes
ad77a9a75e Append output of :set to report. 2010-12-11 00:08:35 -06:00
Israel Chauca Fuentes
5bf35a6b31 Delete empty <CR> expansion with indentation. 2010-12-11 00:07:59 -06:00
Israel Chauca Fuentes
49044099dd Change format of report. 2010-12-11 00:07:19 -06:00
Israel Chauca Fuentes
7c423067a8 UPdate to delimitMateTests#Main(). 2010-12-10 23:26:21 -06:00
Israel Chauca Fuentes
d08fa765b9 Update doc. 2010-12-10 23:25:10 -06:00
Israel Chauca Fuentes
f47bcd8e3f Reorder mappings. 2010-12-08 21:56:47 -06:00
Israel Chauca Fuentes
873e79ec37 Allow jumping over contiguous delimiters. Closes #44. 2010-12-08 03:34:45 -06:00
Israel Chauca Fuentes
589b2ae85a Merge branch 'master' into jump_over 2010-12-07 17:05:00 -06:00
Israel Chauca Fuentes
f9f2b5f177 Don't leave mappings around.
Some mappings weren't being unmapped on filetype change because options
were initialized before the call to Unmap().
2010-12-07 16:59:09 -06:00
Israel Chauca Fuentes
4157dc8a88 Make jumping back optional. 2010-12-06 22:08:59 -06:00
Israel Chauca Fuentes
d0fc1456b7 Use \# to insert closing pair in smart_matchpairs. 2010-11-17 23:17:25 -06:00
Israel Chauca Fuentes
86f70a7d9c Use regex for smart_matchpairs.
If the text in the line to the right of the cursor matches
smart_matchpairs, do not auto close.

To match the opening paren, insert a escaped bang (\!) in the pattern.
2010-11-17 17:53:33 -06:00
Israel Chauca Fuentes
f7b53f045d Fix typo. 2010-11-09 03:19:44 -06:00
Israel Chauca Fuentes
f3d140e363 Update credits section. 2010-11-09 01:12:26 -06:00
Israel Chauca Fuentes
93a1770f37 Doc update. 2010-11-08 09:47:51 -06:00
Israel Chauca Fuentes
859a732509 Merge git://github.com/ervandew/delimitMate into temporal
Conflicts:
	autoload/delimitMate.vim
2010-11-08 09:22:20 -06:00
Israel Chauca Fuentes
eb778be64b Update OptionsList(). 2010-11-06 22:47:05 -05:00
Israel Chauca Fuentes
2b2ae65182 Eliminate some noise from DelimitMateTest. 2010-11-06 22:43:03 -05:00
Israel Chauca Fuentes
e1b52d3676 Some formating. 2010-11-06 22:41:31 -05:00
Israel Chauca Fuentes
ff4745b191 More flexible test for 'backspace' values. 2010-11-06 22:38:13 -05:00
Israel Chauca Fuentes
2ba694830d Use '\w' instead of '[[:alnum:]]' in smart_quotes. 2010-11-06 22:35:40 -05:00
Israel Chauca Fuentes
12c5c96ca2 Add smart_matchpairs
This option will prevent delimitMate from inserting the closing
delimiter when there is a keyword character on the right of the cursor.
2010-11-06 20:05:40 -05:00
ervandew
a97af1fb97 add option to disable closing delims if open delim added before an alphanumeric 2010-11-06 17:15:23 -07:00
Israel Chauca Fuentes
5bf6a1e30c Fix DelimitMateTest. 2010-10-09 17:23:32 -05:00
Israel Chauca Fuentes
f8883cb700 Release 2.5.1. 2010-09-30 18:55:35 -05:00
Israel Chauca Fuentes
f72ffe3c12 b:vars take precedence over g:vars in report. 2010-09-30 18:50:52 -05:00
Israel Chauca Fuentes
d2e896fbe1 Nicer report. 2010-09-29 14:33:14 -05:00
Israel Chauca Fuentes
a0b1799270 Remove Visual Wrapping. Closes #38. 2010-09-27 15:27:45 -05:00
5 changed files with 315 additions and 390 deletions

58
README
View File

@@ -1,4 +1,4 @@
*delimitMate.txt* Trying to keep those beasts at bay! v2.5 *delimitMate* *delimitMate.txt* Trying to keep those beasts at bay! v2.5.1 *delimitMate*
@@ -27,11 +27,10 @@
3.1 Automatic closing & exiting________|delimitMateAutoClose| 3.1 Automatic closing & exiting________|delimitMateAutoClose|
3.2 Expansion of space and CR__________|delimitMateExpansion| 3.2 Expansion of space and CR__________|delimitMateExpansion|
3.3 Backspace__________________________|delimitMateBackspace| 3.3 Backspace__________________________|delimitMateBackspace|
3.4 Visual wrapping____________________|delimitMateVisualWrapping| 3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
3.5 Smart Quotes_______________________|delimitMateSmartQuotes| 3.5 Balancing matching pairs___________|delimitMateBalance|
3.6 Balancing matching pairs___________|delimitMateBalance| 3.6 FileType based configuration_______|delimitMateFileType|
3.7 FileType based configuration_______|delimitMateFileType| 3.7 Syntax awareness___________________|delimitMateSyntax|
3.8 Syntax awareness___________________|delimitMateSyntax|
4. Commands________________________________|delimitMateCommands| 4. Commands________________________________|delimitMateCommands|
5. Mappings________________________________|delimitMateMappings| 5. Mappings________________________________|delimitMateMappings|
6. Functions_______________________________|delimitMateFunctions| 6. Functions_______________________________|delimitMateFunctions|
@@ -88,8 +87,6 @@ specific file types, see |delimitMateOptionDetails| for examples.
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be |'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
allowed to be nested. allowed to be nested.
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>. |'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>. |'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
@@ -178,18 +175,6 @@ e.g.: >
let delimitMate_nesting_quotes = ['"','`'] let delimitMate_nesting_quotes = ['"','`']
au FileType python let b:delimitMate_nesting_quotes = ['"'] au FileType python let b:delimitMate_nesting_quotes = ['"']
< <
------------------------------------------------------------------------------
*'delimitMate_visual_leader'*
*'b:delimitMate_visual_leader'*
Values: Any character. ~
Default: q ~
The value of this option will be used to wrap the selection in visual mode
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
e.g: >
let delimitMate_visual_leader = "f"
au FileType html let b:delimitMate_visual_leader = "f"
<
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'delimitMate_expand_cr'* *'delimitMate_expand_cr'*
*'b:delimitMate_expand_cr'* *'b:delimitMate_expand_cr'*
@@ -373,24 +358,7 @@ e.g. typing at the "|": >
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping* 3.4 SMART QUOTES *delimitMateSmartQuotes*
When visual mode is active this script allows for the selection to be enclosed
with delimiters. But, since brackets have special meaning in visual mode, a
leader (the value of 'mapleader' by default) should precede the delimiter.
NOTE that this feature brakes the repeat command and doesn't currently work
well on blockwise visual mode when the selection has lines one character
smaller than the rest, any suggestions to fix this will be very welcome.
e.g. (selection represented between square brackets): >
Selected text | After \"
=============================================
An [absurd] example! | An "absurd" example!
<
------------------------------------------------------------------------------
3.5 SMART QUOTES *delimitMateSmartQuotes*
Only one quote will be inserted following a quote, a "\" or, following or Only one quote will be inserted following a quote, a "\" or, following or
preceding an alphanumeric character. This should cover closing quotes after a preceding an alphanumeric character. This should cover closing quotes after a
@@ -408,7 +376,7 @@ e.g. typing at the "|": >
'm | I| | I'm| 'm | I| | I'm|
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.6 BALANCING MATCHING PAIRS *delimitMateBalance* 3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
enabled, delimitMate will try to balance the closing pairs in the current enabled, delimitMate will try to balance the closing pairs in the current
@@ -423,7 +391,7 @@ e.g. typing at the "|": >
( | (|) | ((|)) ( | (|) | ((|))
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.7 FILE TYPE BASED CONFIGURATION *delimitMateFileType* 3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
delimitMate options can be set globally for all buffers using global delimitMate options can be set globally for all buffers using global
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set ("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
@@ -443,7 +411,7 @@ NOTE that you should use buffer variables (|b:var|) only to set options with
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc. |:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.8 SYNTAX AWARENESS *delimitMateSyntax* 3.7 SYNTAX AWARENESS *delimitMateSyntax*
The features of this plug-in might not be always helpful, comments and strings The features of this plug-in might not be always helpful, comments and strings
usualy don't need auto-completion. delimitMate monitors which region is being usualy don't need auto-completion. delimitMate monitors which region is being
@@ -668,8 +636,12 @@ This script was inspired by the auto-completion of delimiters on TextMate.
Version Date Release notes ~ Version Date Release notes ~
|---------|------------|-----------------------------------------------------| |---------|------------|-----------------------------------------------------|
2.5 2010-09-22 * Current release: 2.5.1 2010-09-30 * Current release:
- Better handling of mappings. - Remove visual wrapping. Surround.vim offers a much
better implementation.
- Minor mods to DelimitMateTest.
|---------|------------|-----------------------------------------------------|
2.5 2010-09-22 * - Better handling of mappings.
- Add report for mappings in |:DelimitMateTest|. - Add report for mappings in |:DelimitMateTest|.
- Allow the use of "|" and multi-byte characters in - Allow the use of "|" and multi-byte characters in
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|. |'delimitMate_quotes'| and |'delimitMate_matchpairs'|.

View File

@@ -1,10 +1,10 @@
" ============================================================================
" File: autoload/delimitMate.vim " File: autoload/delimitMate.vim
" Version: 2.5 " Version: 2.6
" Modified: 2010-09-22 " Modified: 2011-01-14
" Description: This plugin provides auto-completion for quotes, parens, etc. " Description: This plugin provides auto-completion for quotes, parens, etc.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com> " Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" Manual: Read ":help delimitMate". " Manual: Read ":help delimitMate".
" ============================================================================
" Utilities {{{ " Utilities {{{
@@ -46,47 +46,6 @@ function! delimitMate#ShouldJump() "{{{
return 0 return 0
endfunction "}}} endfunction "}}}
function! delimitMate#Visual(del) " {{{
if len(getline('.')) == 0
" This for proper wrap of empty lines.
let @" = "\n"
endif
" Let's find which kind of delimiter we got:
let index = index(b:_l_delimitMate_left_delims, a:del)
if index >= 0
let ld = a:del
let rd = b:_l_delimitMate_right_delims[index]
endif
let index = index(b:_l_delimitMate_right_delims, a:del)
if index >= 0
let ld = b:_l_delimitMate_left_delims[index]
let rd = a:del
endif
if index(b:_l_delimitMate_quotes_list, a:del) >= 0
let ld = a:del
let rd = ld
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>"
endfunction " }}}
function! delimitMate#IsEmptyPair(str) "{{{ function! delimitMate#IsEmptyPair(str) "{{{
for pair in b:_l_delimitMate_matchpairs_list for pair in b:_l_delimitMate_matchpairs_list
if a:str == join( split( pair, ':' ),'' ) if a:str == join( split( pair, ':' ),'' )
@@ -168,12 +127,6 @@ function! delimitMate#WriteAfter(str) "{{{
return '' return ''
endfunction " }}} endfunction " }}}
function! delimitMate#RestoreRegister() " {{{
" Restore unnamed register values stored in delimitMate#Visual().
call setreg('"', b:save_reg, b:save_reg_mode)
echo ""
endfunction " }}}
function! delimitMate#GetSyntaxRegion(line, col) "{{{ function! delimitMate#GetSyntaxRegion(line, col) "{{{
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name') return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
endfunction " }}} endfunction " }}}
@@ -262,6 +215,13 @@ function! delimitMate#BalancedParens(char) "{{{
return opening - closing return opening - closing
endfunction "}}} endfunction "}}}
function! delimitMate#RmBuffer(num) " {{{
if len(b:_l_delimitMate_buffer) > 0
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
endif
return ""
endfunction " }}}
" }}} " }}}
" Doers {{{ " Doers {{{
@@ -299,13 +259,21 @@ function! delimitMate#ParenDelim(char) " {{{
if delimitMate#IsForbidden(a:char) if delimitMate#IsForbidden(a:char)
return '' return ''
endif endif
" Try to balance matchpairs
if b:_l_delimitMate_balance_matchpairs && if b:_l_delimitMate_balance_matchpairs &&
\ delimitMate#BalancedParens(a:char) <= 0 \ delimitMate#BalancedParens(a:char) <= 0
return '' return ''
endif endif
let line = getline('.') let line = getline('.')
let col = col('.')-2 let col = col('.')-2
if (col) < 0 let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims,a:char)]
let smart_matchpairs = substitute(b:_l_delimitMate_smart_matchpairs, '\\!', left, 'g')
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:char, 'g')
"echom left.':'.smart_matchpairs . ':' . matchstr(line[col+1], smart_matchpairs)
if b:_l_delimitMate_smart_matchpairs != '' &&
\ line[col+1:] =~ smart_matchpairs
return ''
elseif (col) < 0
call setline('.',a:char.line) call setline('.',a:char.line)
call insert(b:_l_delimitMate_buffer, a:char) call insert(b:_l_delimitMate_buffer, a:char)
else else
@@ -329,10 +297,10 @@ function! delimitMate#QuoteDelim(char) "{{{
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0 \ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
" Get out of the string. " Get out of the string.
return a:char . delimitMate#Del() return a:char . delimitMate#Del()
elseif (line[col] =~ '[[:alnum:]]' && a:char == "'") || elseif (line[col] =~ '\w' && a:char == "'") ||
\ (b:_l_delimitMate_smart_quotes && \ (b:_l_delimitMate_smart_quotes &&
\ (line[col] =~ '[[:alnum:]]' || \ (line[col] =~ '\w' ||
\ line[col + 1] =~ '[[:alnum:]]')) \ line[col + 1] =~ '\w'))
" Seems like an apostrophe or a smart quote case, insert a single quote. " Seems like an apostrophe or a smart quote case, insert a single quote.
return a:char return a:char
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes
@@ -385,11 +353,31 @@ function! delimitMate#JumpAny(key) " {{{
endif endif
endfunction " delimitMate#JumpAny() }}} endfunction " delimitMate#JumpAny() }}}
function! delimitMate#MapMsg(msg) "{{{ function! delimitMate#JumpMany() " {{{
redraw let line = getline('.')[col('.') - 1 : ]
echomsg a:msg let len = len(line)
return "" let rights = ""
endfunction "}}} let found = 0
let i = 0
while i < len
let char = line[i]
if index(b:_l_delimitMate_quotes_list, char) >= 0 ||
\ index(b:_l_delimitMate_right_delims, char) >= 0
let rights .= "\<Right>"
let found = 1
elseif found == 0
let rights .= "\<Right>"
else
break
endif
let i += 1
endwhile
if found == 1
return rights
else
return ''
endif
endfunction " delimitMate#JumpMany() }}}
function! delimitMate#ExpandReturn() "{{{ function! delimitMate#ExpandReturn() "{{{
if delimitMate#IsForbidden("") if delimitMate#IsForbidden("")
@@ -448,7 +436,7 @@ function! delimitMate#Del() " {{{
endif endif
endfunction " }}} endfunction " }}}
function! delimitMate#Finish() " {{{ function! delimitMate#Finish(move_back) " {{{
let len = len(b:_l_delimitMate_buffer) let len = len(b:_l_delimitMate_buffer)
if len > 0 if len > 0
let buffer = join(b:_l_delimitMate_buffer, '') let buffer = join(b:_l_delimitMate_buffer, '')
@@ -464,8 +452,8 @@ function! delimitMate#Finish() " {{{
call setline('.', line[:col] . line[col+len2+1:]) call setline('.', line[:col] . line[col+len2+1:])
endif endif
let i = 1 let i = 1
let lefts = "\<Left>" let lefts = ""
while i < len while i <= len && a:move_back
let lefts = lefts . "\<Left>" let lefts = lefts . "\<Left>"
let i += 1 let i += 1
endwhile endwhile
@@ -474,71 +462,16 @@ function! delimitMate#Finish() " {{{
return '' return ''
endfunction " }}} endfunction " }}}
function! delimitMate#RmBuffer(num) " {{{
if len(b:_l_delimitMate_buffer) > 0
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
endif
return ""
endfunction " }}}
" }}} " }}}
" Tools: {{{ " Tools: {{{
function! delimitMate#TestMappings() "{{{ function! delimitMate#TestMappings() "{{{
let options = sort(keys(delimitMate#OptionsList())) let options = sort(keys(delimitMate#OptionsList()))
let optoutput = ['delimitMate Report', '', 'Options:'] let optoutput = ['delimitMate Report', '==================', '', '* Options: ( ) default, (g) global, (b) buffer','']
for option in options for option in options
exec 'call add(optoutput, ''delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))' exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b' : exists('g:delimitMate_'.option) ? 'g' : ' ').') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))'
endfor endfor
call append(line('$'), optoutput + ['','Showcase:', '']) call append(line('$'), optoutput + ['--------------------',''])
if b:_l_delimitMate_autoclose
" {{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal GGoOpen: " . b:_l_delimitMate_left_delims[i]. "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
endfor
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal GGAOpen: " . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
endfor
"}}}
else
"{{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal GGoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
endfor
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal GGoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
endfor
endif "}}}
" Check if mappings were set. {{{ " Check if mappings were set. {{{
let imaps = b:_l_delimitMate_right_delims let imaps = b:_l_delimitMate_right_delims
@@ -548,7 +481,7 @@ function! delimitMate#TestMappings() "{{{
\ b:_l_delimitMate_apostrophes_list + \ b:_l_delimitMate_apostrophes_list +
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] + \ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] + \ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>'] \ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] ) let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] )
let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] ) let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] )
@@ -568,38 +501,85 @@ function! delimitMate#TestMappings() "{{{
let ibroken = ibroken + [map.": is not set:"] + split(output, '\n') let ibroken = ibroken + [map.": is not set:"] + split(output, '\n')
endif endif
endfor endfor
let ibroken = len(ibroken) > 0 ? ['IMAP'] + ibroken : []
let vbroken = []
if !exists("b:_l_delimitMate_visual_leader")
let vleader = ""
else
let vleader = b:_l_delimitMate_visual_leader
endif
for map in vmaps
if maparg(vleader . map, "v") !~? "delimitMate"
let output = ''
if map == '|'
let map = '<Bar>'
endif
redir => output | execute "verbose imap ".map | redir END
let vbroken = vbroken + [vleader.map.": is not set:"] + split(output,'\n')
endif
endfor
let vbroken = len(vbroken) > 0 ? ['VMAP'] + vbroken : []
unlet! output unlet! output
if ibroken == [] && vbroken == [] if ibroken == []
let output = ['Mappings:', '', 'All mappings were set-up.', '--------------------', '', ''] let output = ['* Mappings:', '', 'All mappings were set-up.', '--------------------', '', '']
else else
let output = ['Mappings:', ''] + ibroken + vbroken + ['--------------------', '', ''] let output = ['* Mappings:', ''] + ibroken + ['--------------------', '']
endif endif
call append('$', output) call append('$', output+['* Showcase:', ''])
" }}} " }}}
if b:_l_delimitMate_autoclose
" {{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_left_delims[i]. "|"
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_left_delims[i] . " |"
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>0\<C-D>\<BS>|"
endif
call append(line('$'), '')
endfor
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
endif
call append(line('$'), '')
endfor
"}}}
else
"{{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal GoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
exec "normal GoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|"
endif
call append(line('$'), '')
endfor
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal GoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
endif
call append(line('$'), '')
endfor
endif "}}}
redir => setoptions | set | filetype | redir END
call append(line('$'), split(setoptions,"\n")
\ + ['--------------------'])
setlocal nowrap
endfunction "}}} endfunction "}}}
function! delimitMate#OptionsList() "{{{ function! delimitMate#OptionsList() "{{{
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'visual_leader' : ( exists('mapleader') ? mapleader : exists('b:maplocalleader') ? b:maplocalleader : '\' ), 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''} return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'smart_matchpairs' : '\w', 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
endfunction " delimitMate#OptionsList }}} endfunction " delimitMate#OptionsList }}}
"}}} "}}}

View File

@@ -3,7 +3,7 @@ function! delimitMateTests#Main()
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value." echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
return return
elseif g:delimitMate_testing == "fork" elseif g:delimitMate_testing == "fork"
!gvim -N -u NONE -U NONE -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "so autoload/delimitMate.vim" -c "so autoload/delimitMateTests.vim" -c "so plugin/delimitMate.vim" -c "call delimitMateTests\#Main()" !gvim -N -u NONE -U NONE -c "set runtimepath+=~/.vim/bundle/pathogen" -c "call pathogen\#runtime_append_all_bundles('bundle','symlinks')" -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "ru autoload/delimitMate.vim" -c "ru autoload/delimitMateTests.vim" -c "ru plugin/delimitMate.vim" -c "call delimitMateTests\#Main()"
return "" return ""
endif endif
nmap <F1> :qall!<CR> nmap <F1> :qall!<CR>
@@ -19,7 +19,6 @@ function! delimitMateTests#Main()
let b:delimitMate_matchpairs = &matchpairs let b:delimitMate_matchpairs = &matchpairs
let b:delimitMate_quotes = "\" ' `" let b:delimitMate_quotes = "\" ' `"
let b:delimitMate_excluded_regions = "Comment" let b:delimitMate_excluded_regions = "Comment"
silent! unlet b:delimitMate_visual_leader
let b:delimitMate_expand_space = 0 let b:delimitMate_expand_space = 0
let b:delimitMate_expand_cr = 0 let b:delimitMate_expand_cr = 0
let b:delimitMate_smart_quotes = 1 let b:delimitMate_smart_quotes = 1
@@ -164,36 +163,6 @@ function! delimitMateTests#Main()
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1']) call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
call RepeatLast("BS with CR expansion", ['(|)(|)'], 1) call RepeatLast("BS with CR expansion", ['(|)(|)'], 1)
" Visual wrapping
call Type("Visual wrapping left paren", "1234\<Esc>v,(", ['123(4)'], ['visual_leader:","'])
cal RepeatLast("Visual wrapping left paren", ['(1)23(4)'], 1)
" Visual line wrapping
call Type("Visual line wrapping left paren", "1234\<Esc>V,(", ['(1234)'], ['visual_leader:","'])
cal RepeatLast("Visual line wrapping left paren", ['((1234))'], 1)
" Visual wrapping
call Type("Visual wrapping right paren", "1234\<Esc>v,)", ['123(4)'], ['visual_leader:","'])
cal RepeatLast("Visual wrapping right paren", ['(1)23(4)'], 1)
" Visual line wrapping
call Type("Visual line wrapping right paren", "1234\<Esc>V,)", ['(1234)'], ['visual_leader:","'])
cal RepeatLast("Visual line wrapping right paren", ['((1234))'], 1)
" Visual wrapping
call Type("Visual wrapping quote", "1234\<Esc>v,\"", ['123"4"'], ['visual_leader:","'])
cal RepeatLast("Visual wrapping quote", ['"1"23"4"'], 1)
" Visual line wrapping
call Type("Visual line wrapping quote", "1234\<Esc>V,\"", ['"1234"'], ['visual_leader:","'])
cal RepeatLast("Visual line wrapping quote", ['""1234""'], 1)
" Visual line wrapping empty line
call Type("Visual line wrapping paren empty line", "\<Esc>V,(", ['()'], ['visual_leader:","'])
" Visual line wrapping empty line
call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","'])
" Smart quotes " Smart quotes
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], []) call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|']) call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])

View File

@@ -1,4 +1,4 @@
*delimitMate.txt* Trying to keep those beasts at bay! v2.5 *delimitMate* *delimitMate.txt* Trying to keep those beasts at bay! v2.6 *delimitMate*
@@ -27,11 +27,10 @@
3.1 Automatic closing & exiting________|delimitMateAutoClose| 3.1 Automatic closing & exiting________|delimitMateAutoClose|
3.2 Expansion of space and CR__________|delimitMateExpansion| 3.2 Expansion of space and CR__________|delimitMateExpansion|
3.3 Backspace__________________________|delimitMateBackspace| 3.3 Backspace__________________________|delimitMateBackspace|
3.4 Visual wrapping____________________|delimitMateVisualWrapping| 3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
3.5 Smart Quotes_______________________|delimitMateSmartQuotes| 3.5 Balancing matching pairs___________|delimitMateBalance|
3.6 Balancing matching pairs___________|delimitMateBalance| 3.6 FileType based configuration_______|delimitMateFileType|
3.7 FileType based configuration_______|delimitMateFileType| 3.7 Syntax awareness___________________|delimitMateSyntax|
3.8 Syntax awareness___________________|delimitMateSyntax|
4. Commands________________________________|delimitMateCommands| 4. Commands________________________________|delimitMateCommands|
5. Mappings________________________________|delimitMateMappings| 5. Mappings________________________________|delimitMateMappings|
6. Functions_______________________________|delimitMateFunctions| 6. Functions_______________________________|delimitMateFunctions|
@@ -88,14 +87,14 @@ specific file types, see |delimitMateOptionDetails| for examples.
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be |'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
allowed to be nested. allowed to be nested.
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>. |'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>. |'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature. |'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|'delimitMate_smart_matchpairs'| Turns on/off the "smart matchpairs" feature.
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs" |'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
feature. feature.
@@ -178,18 +177,6 @@ e.g.: >
let delimitMate_nesting_quotes = ['"','`'] let delimitMate_nesting_quotes = ['"','`']
au FileType python let b:delimitMate_nesting_quotes = ['"'] au FileType python let b:delimitMate_nesting_quotes = ['"']
< <
------------------------------------------------------------------------------
*'delimitMate_visual_leader'*
*'b:delimitMate_visual_leader'*
Values: Any character. ~
Default: q ~
The value of this option will be used to wrap the selection in visual mode
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
e.g: >
let delimitMate_visual_leader = "f"
au FileType html let b:delimitMate_visual_leader = "f"
<
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'delimitMate_expand_cr'* *'delimitMate_expand_cr'*
*'b:delimitMate_expand_cr'* *'b:delimitMate_expand_cr'*
@@ -197,7 +184,8 @@ Values: 1 or 0 ~
Default: 0 ~ Default: 0 ~
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion| This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
for details. for details. NOTE This feature requires that 'backspace' is either set to 2 or
has "eol" and "start" as part of its value.
e.g.: > e.g.: >
let delimitMate_expand_cr = 1 let delimitMate_expand_cr = 1
au FileType mail let b:delimitMate_expand_cr = 1 au FileType mail let b:delimitMate_expand_cr = 1
@@ -207,7 +195,6 @@ e.g.: >
*'b:delimitMate_expand_space'* *'b:delimitMate_expand_space'*
Values: 1 or 0 ~ Values: 1 or 0 ~
Default: 0 ~ Default: 0 ~
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion| This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
for details. for details.
e.g.: > e.g.: >
@@ -224,7 +211,22 @@ This option turns on/off the smart quotes feature. Read
|delimitMateSmartQuotes| for details. |delimitMateSmartQuotes| for details.
e.g.: > e.g.: >
let delimitMate_smart_quotes = 0 let delimitMate_smart_quotes = 0
au FileType tcl let b:delimitMate_smart_quotes = 0 au FileType tcl let b:delimitMate_smart_quotes = 1
<
------------------------------------------------------------------------------
*'delimitMate_smart_matchpairs'*
*'b:delimitMate_smart_matchpairs'*
Values: Regexp ~
Default: '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)' ~
This regex is matched against the text to the right of cursor, if it's not
empty and there is a match delimitMate will not autoclose the pair. At the
moment to match the text, an escaped bang (\!) in the regex will be replaced
by the character being inserted, while an escaped number symbol (\#) will be
replaced by the closing pair.
e.g.: >
let delimitMate_smart_matchpairs = ''
au FileType tcl let b:delimitMate_smart_matchpairs = '^\%(\w\|\$\)'
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'delimitMate_balance_matchpairs'* *'delimitMate_balance_matchpairs'*
@@ -289,31 +291,42 @@ When the cursor is inside an empty pair or located next to the left of a
closing delimiter, the cursor is placed outside the pair to the right of the closing delimiter, the cursor is placed outside the pair to the right of the
closing delimiter. closing delimiter.
When |'delimitMate_smart_matchpairs'| is not empty and it matches the text to
the right of the cursor, delimitMate will not automatically insert the closing
pair.
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'| are set, this Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'| are set, this
script uses the values in '&matchpairs' to identify the pairs, and ", ' and ` script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
for quotes respectively. for quotes respectively.
<S-Tab> will jump over a single closing delimiter or quote, <C-G>g will jump
over contiguous delimiters and/or quotes.
The following table shows the behaviour, this applies to quotes too (the final The following table shows the behaviour, this applies to quotes too (the final
position of the cursor is represented by a "|"): position of the cursor is represented by a "|"):
With auto-close: > With auto-close: >
Type | You get Type | You get
==================== =======================
( | (|) ( | (|)
| |
() | ()| () | ()|
| |
(<S-Tab> | ()| (<S-Tab> | ()|
|
{("<C-G>g | {("")}|
< <
Without auto-close: > Without auto-close: >
Type | You get Type | You get
===================== =========================
() | (|) () | (|)
-| -----|
()) | ()| ()) | ()|
-| -----|
()<S-Tab> | ()| ()<S-Tab> | ()|
|
{}()""<C-G>g | {("")}|
< <
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate, NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
you should use <C-]> (read |i_CTRL-]|) to expand them on the go. you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
@@ -373,27 +386,10 @@ e.g. typing at the "|": >
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping* 3.4 SMART QUOTES *delimitMateSmartQuotes*
When visual mode is active this script allows for the selection to be enclosed
with delimiters. But, since brackets have special meaning in visual mode, a
leader (the value of 'mapleader' by default) should precede the delimiter.
NOTE that this feature brakes the repeat command and doesn't currently work
well on blockwise visual mode when the selection has lines one character
smaller than the rest, any suggestions to fix this will be very welcome.
e.g. (selection represented between square brackets): >
Selected text | After \"
=============================================
An [absurd] example! | An "absurd" example!
<
------------------------------------------------------------------------------
3.5 SMART QUOTES *delimitMateSmartQuotes*
Only one quote will be inserted following a quote, a "\" or, following or Only one quote will be inserted following a quote, a "\" or, following or
preceding an alphanumeric character. This should cover closing quotes after a preceding a keyword character. This should cover closing quotes after a
string, opening quotes before a string, escaped quotes and apostrophes. Except string, opening quotes before a string, escaped quotes and apostrophes. Except
for apostrophes, this feature can be disabled setting the option for apostrophes, this feature can be disabled setting the option
|'delimitMate_smart_quotes'| to 0. |'delimitMate_smart_quotes'| to 0.
@@ -408,7 +404,23 @@ e.g. typing at the "|": >
'm | I| | I'm| 'm | I| | I'm|
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.6 BALANCING MATCHING PAIRS *delimitMateBalance* 3.4 SMART MATCHPAIRS *delimitMateSmartMatchpairs*
This is similar to "smart quotes", but applied to the characters in
|'delimitMate_matchpairs'|. The difference is that delimitMate will not
auto-close the pair when the regex matches the text on the right of the
cursor. See |'delimitMate_smart_matchpairs'| for more details.
e.g. typing at the "|": >
What | Before | After
=======================================
( | function| | function(|)
( | |var | (|var
<
------------------------------------------------------------------------------
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
enabled, delimitMate will try to balance the closing pairs in the current enabled, delimitMate will try to balance the closing pairs in the current
@@ -418,12 +430,12 @@ e.g. typing at the "|": >
What | Before | After What | Before | After
======================================= =======================================
( | |) | (|)
( | | | (|) ( | | | (|)
( | (|) | ((|)) ( | |) | (|)
(( | |) | ((|))
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.7 FILE TYPE BASED CONFIGURATION *delimitMateFileType* 3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
delimitMate options can be set globally for all buffers using global delimitMate options can be set globally for all buffers using global
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set ("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
@@ -443,7 +455,7 @@ NOTE that you should use buffer variables (|b:var|) only to set options with
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc. |:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.8 SYNTAX AWARENESS *delimitMateSyntax* 3.7 SYNTAX AWARENESS *delimitMateSyntax*
The features of this plug-in might not be always helpful, comments and strings The features of this plug-in might not be always helpful, comments and strings
usualy don't need auto-completion. delimitMate monitors which region is being usualy don't need auto-completion. delimitMate monitors which region is being
@@ -553,11 +565,12 @@ In order to make custom mappings easier and prevent overwritting existing
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
for its mappings. for its mappings.
The following are the mappings alway set by delimitMate: These are the default mappings:
<BS> is mapped to <Plug>delimitMateBS <BS> is mapped to <Plug>delimitMateBS
<S-BS> is mapped to <Plug>delimitMateS-BS <S-BS> is mapped to <Plug>delimitMateS-BS
<S-Tab> is mapped to <Plug>delimitMateS-Tab <S-Tab> is mapped to <Plug>delimitMateS-Tab
<C-G>g is mapped to <Plug>delimitMateJumpMany
<Del> is mapped to <Plug>delimitMateDel <Del> is mapped to <Plug>delimitMateDel
<Esc> is mapped to <Plug>delimitMateEsc <Esc> is mapped to <Plug>delimitMateEsc
<Left> is mapped to <Plug>delimitMateLeft <Left> is mapped to <Plug>delimitMateLeft
@@ -594,7 +607,7 @@ menus:
6. FUNCTIONS *delimitMateFunctions* 6. FUNCTIONS *delimitMateFunctions*
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()* delimitMate#WithinEmptyPair() *delimitMate#WithinEmptyPair()*
Returns 1 if the cursor is inside an empty pair, 0 otherwise. Returns 1 if the cursor is inside an empty pair, 0 otherwise.
e.g.: > e.g.: >
@@ -638,26 +651,34 @@ be very pleased to read them.
============================================================================== ==============================================================================
9. CREDITS *delimitMateCredits* 9. CREDITS *delimitMateCredits*
Some of the code that make this script is modified or just shamelessly copied Contributors: ~
from the following sources:
- Ian McCracken - Kim Silkebækken ~
Fixed mappings being echoed in the terminal.
- Eric Van Dewoestine ~
Implemented smart matchpairs.
Some of the code that makes this script was modified or just shamelessly
copied from the following sources:
- Ian McCracken ~
Post titled: Vim, Part II: Matching Pairs: Post titled: Vim, Part II: Matching Pairs:
http://concisionandconcinnity.blogspot.com/ http://concisionandconcinnity.blogspot.com/
- Aristotle Pagaltzis - Aristotle Pagaltzis ~
From the comments on the previous blog post and from: From the comments on the previous blog post and from:
http://gist.github.com/144619 http://gist.github.com/144619
- Karl Guertin - Karl Guertin ~
AutoClose: AutoClose:
http://www.vim.org/scripts/script.php?script_id=1849 http://www.vim.org/scripts/script.php?script_id=1849
- Thiago Alves - Thiago Alves ~
AutoClose: AutoClose:
http://www.vim.org/scripts/script.php?script_id=2009 http://www.vim.org/scripts/script.php?script_id=2009
- Edoardo Vacchi - Edoardo Vacchi ~
ClosePairs: ClosePairs:
http://www.vim.org/scripts/script.php?script_id=2373 http://www.vim.org/scripts/script.php?script_id=2373
@@ -668,8 +689,16 @@ This script was inspired by the auto-completion of delimiters on TextMate.
Version Date Release notes ~ Version Date Release notes ~
|---------|------------|-----------------------------------------------------| |---------|------------|-----------------------------------------------------|
2.5 2010-09-22 * Current release: 2.6 2011-01-14 * Current release:
- Better handling of mappings. - Add smart_matchpairs feature.
- Add mapping to jump over contiguous delimiters.
- Fix behaviour of b:loaded_delimitMate.
|---------|------------|-----------------------------------------------------|
2.5.1 2010-09-30 * - Remove visual wrapping. Surround.vim offers a much
better implementation.
- Minor mods to DelimitMateTest.
|---------|------------|-----------------------------------------------------|
2.5 2010-09-22 * - Better handling of mappings.
- Add report for mappings in |:DelimitMateTest|. - Add report for mappings in |:DelimitMateTest|.
- Allow the use of "|" and multi-byte characters in - Allow the use of "|" and multi-byte characters in
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|. |'delimitMate_quotes'| and |'delimitMate_matchpairs'|.

View File

@@ -1,10 +1,10 @@
" ============================================================================
" File: plugin/delimitMate.vim " File: plugin/delimitMate.vim
" Version: 2.5 " Version: 2.6
" Modified: 2010-09-22 " Modified: 2011-01-14
" Description: This plugin provides auto-completion for quotes, parens, etc. " Description: This plugin provides auto-completion for quotes, parens, etc.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com> " Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" Manual: Read ":help delimitMate". " Manual: Read ":help delimitMate".
" ============================================================================
" Initialization: {{{ " Initialization: {{{
@@ -27,7 +27,7 @@ if v:version < 700
endif endif
let s:loaded_delimitMate = 1 let s:loaded_delimitMate = 1
let delimitMate_version = "2.5" let delimitMate_version = "2.6"
function! s:option_init(name, default) "{{{ function! s:option_init(name, default) "{{{
let b = exists("b:delimitMate_" . a:name) let b = exists("b:delimitMate_" . a:name)
@@ -76,11 +76,6 @@ function! s:init() "{{{
" excluded filetypes " excluded filetypes
call s:option_init("excluded_ft", "") call s:option_init("excluded_ft", "")
" visual_leader
let leader = exists('b:maplocalleader') ? b:maplocalleader :
\ exists('g:mapleader') ? g:mapleader : "\\"
call s:option_init("visual_leader", leader)
" expand_space " expand_space
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("") if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!" echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
@@ -109,14 +104,16 @@ function! s:init() "{{{
unlet g:delimitMate_expand_cr unlet g:delimitMate_expand_cr
let g:delimitMate_expand_cr = 1 let g:delimitMate_expand_cr = 1
endif endif
if (&backspace !~ 'eol' || &backspace !~ 'start') && if ((&backspace !~ 'eol' || &backspace !~ 'start') && &backspace != 2) &&
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) || \ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1)) \ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
echom "delimitMate: In order to use the <CR> expansion, you need to have 'eol' and 'start' in your backspace option. Read :help 'backspace'." echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details."
let b:delimitMate_expand_cr = 0
endif endif
call s:option_init("expand_cr", 0) call s:option_init("expand_cr", 0)
" smart_matchpairs
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)')
" smart_quotes " smart_quotes
call s:option_init("smart_quotes", 1) call s:option_init("smart_quotes", 1)
@@ -132,8 +129,6 @@ function! s:init() "{{{
let b:_l_delimitMate_buffer = [] let b:_l_delimitMate_buffer = []
let b:loaded_delimitMate = 1
endfunction "}}} Init() endfunction "}}} Init()
"}}} "}}}
@@ -154,7 +149,6 @@ function! s:Map() "{{{
else else
call s:NoAutoClose() call s:NoAutoClose()
endif endif
call s:VisualMaps()
call s:ExtraMappings() call s:ExtraMappings()
finally finally
let &cpo = save_cpo let &cpo = save_cpo
@@ -175,12 +169,7 @@ function! s:Unmap() " {{{
\ b:_l_delimitMate_apostrophes_list + \ b:_l_delimitMate_apostrophes_list +
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] + \ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] + \ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>'] \ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
let vmaps =
\ b:_l_delimitMate_right_delims +
\ b:_l_delimitMate_left_delims +
\ b:_l_delimitMate_quotes_list
for map in imaps for map in imaps
if maparg(map, "i") =~? 'delimitMate' if maparg(map, "i") =~? 'delimitMate'
@@ -191,20 +180,6 @@ function! s:Unmap() " {{{
endif endif
endfor endfor
if !exists("b:_l_delimitMate_visual_leader")
let vleader = ""
else
let vleader = b:_l_delimitMate_visual_leader
endif
for map in vmaps
if map == '|'
let map = '<Bar>'
endif
if maparg(vleader . map, "v") =~? "delimitMate"
exec 'silent! vunmap <buffer> ' . vleader . map
endif
endfor
if !has('gui_running') if !has('gui_running')
silent! iunmap <C-[>OC silent! iunmap <C-[>OC
endif endif
@@ -227,7 +202,7 @@ function! s:TestMappingsDo() "{{{
call s:Unmap() call s:Unmap()
call s:Map() call s:Map()
call delimitMate#TestMappings() call delimitMate#TestMappings()
normal o call append(line('$'),'')
endfor endfor
endfor endfor
let b:delimitMate_expand_space = temp_varsDM[0] let b:delimitMate_expand_space = temp_varsDM[0]
@@ -236,28 +211,32 @@ function! s:TestMappingsDo() "{{{
unlet temp_varsDM unlet temp_varsDM
endif endif
normal gg normal gg
g/\%^$/d
endfunction "}}} endfunction "}}}
function! s:DelimitMateDo(...) "{{{ function! s:DelimitMateDo(...) "{{{
" Initialize settings:
call s:init()
" Check if this file type is excluded:
if exists("g:delimitMate_excluded_ft") &&
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
" Remove any magic:
call s:Unmap()
" Finish here:
return 1
endif
" First, remove all magic, if needed: " First, remove all magic, if needed:
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1 if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
call s:Unmap() call s:Unmap()
endif endif
" Check if this file type is excluded:
if exists("g:delimitMate_excluded_ft") &&
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
" Finish here:
return 1
endif
" Check if user tried to disable using b:loaded_delimitMate
if exists("b:loaded_delimitMate")
return 1
endif
" Initialize settings:
call s:init()
" Now, add magic: " Now, add magic:
call s:Map() call s:Map()
@@ -267,30 +246,30 @@ function! s:DelimitMateDo(...) "{{{
endfunction "}}} endfunction "}}}
function! s:DelimitMateSwitch() "{{{ function! s:DelimitMateSwitch() "{{{
call s:init()
if exists("b:delimitMate_enabled") && b:delimitMate_enabled if exists("b:delimitMate_enabled") && b:delimitMate_enabled
call s:Unmap() call s:Unmap()
echo "delimitMate has been disabled." echo "delimitMate has been disabled."
else else
call s:Unmap() call s:Unmap()
call s:init()
call s:Map() call s:Map()
echo "delimitMate has been enabled." echo "delimitMate has been enabled."
endif endif
endfunction "}}} endfunction "}}}
function! s:Finish() function! s:Finish() " {{{
if exists('g:delimitMate_loaded') if exists('g:delimitMate_loaded')
return delimitMate#Finish() return delimitMate#Finish(1)
endif endif
return '' return ''
endfunction endfunction " }}}
function! s:FlushBuffer() function! s:FlushBuffer() " {{{
if exists('g:delimitMate_loaded') if exists('g:delimitMate_loaded')
return delimitMate#FlushBuffer() return delimitMate#FlushBuffer()
endif endif
return '' return ''
endfunction endfunction " }}}
"}}} "}}}
@@ -342,29 +321,37 @@ function! s:AutoClose() "{{{
endfor endfor
endfunction "}}} endfunction "}}}
function! s:VisualMaps() " {{{
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
let vleader = b:_l_delimitMate_visual_leader
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
for del in b:_l_delimitMate_right_delims + b:_l_delimitMate_left_delims + b:_l_delimitMate_quotes_list
exec "vnoremap <silent> <expr> <Plug>delimitMateVisual" . del . ' delimitMate#Visual("' . escape(del, '")|') . '")'
exec 'silent! vmap <unique> <buffer> ' . vleader . del . ' <Plug>delimitMateVisual' . del
endfor
endfunction "}}}
function! s:ExtraMappings() "{{{ function! s:ExtraMappings() "{{{
" If pair is empty, delete both delimiters: " If pair is empty, delete both delimiters:
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR> inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
if !hasmapto('<Plug>delimitMateBS','i')
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
endif
" If pair is empty, delete closing delimiter: " If pair is empty, delete closing delimiter:
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>" inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
if !hasmapto('<Plug>delimitMateS-BS','i')
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
endif
" Expand return if inside an empty pair: " Expand return if inside an empty pair:
inoremap <silent> <Plug>delimitMateCR <C-R>=delimitMate#ExpandReturn()<CR> inoremap <silent> <Plug>delimitMateCR <C-R>=delimitMate#ExpandReturn()<CR>
if b:_l_delimitMate_expand_cr != 0 && !hasmapto('<Plug>delimitMateCR', 'i')
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
endif
" Expand space if inside an empty pair: " Expand space if inside an empty pair:
inoremap <silent> <Plug>delimitMateSpace <C-R>=delimitMate#ExpandSpace()<CR> inoremap <silent> <Plug>delimitMateSpace <C-R>=delimitMate#ExpandSpace()<CR>
" Jump out ot any empty pair: if b:_l_delimitMate_expand_space != 0 && !hasmapto('<Plug>delimitMateSpace', 'i')
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
endif
" Jump over any delimiter:
inoremap <silent> <Plug>delimitMateS-Tab <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR> inoremap <silent> <Plug>delimitMateS-Tab <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
if b:_l_delimitMate_tab2exit && !hasmapto('<Plug>delimitMateS-Tab', 'i')
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
endif
" Change char buffer on Del: " Change char buffer on Del:
inoremap <silent> <Plug>delimitMateDel <C-R>=delimitMate#Del()<CR> inoremap <silent> <Plug>delimitMateDel <C-R>=delimitMate#Del()<CR>
if !hasmapto('<Plug>delimitMateDel', 'i')
silent! imap <unique> <buffer> <Del> <Plug>delimitMateDel
endif
" Flush the char buffer on movement keystrokes or when leaving insert mode: " Flush the char buffer on movement keystrokes or when leaving insert mode:
for map in ['Esc', 'Left', 'Right', 'Home', 'End'] for map in ['Esc', 'Left', 'Right', 'Home', 'End']
exec 'inoremap <silent> <Plug>delimitMate'.map.' <C-R>=<SID>Finish()<CR><'.map.'>' exec 'inoremap <silent> <Plug>delimitMate'.map.' <C-R>=<SID>Finish()<CR><'.map.'>'
@@ -381,31 +368,18 @@ function! s:ExtraMappings() "{{{
endfor endfor
" Avoid ambiguous mappings: " Avoid ambiguous mappings:
for map in ['LeftMouse', 'RightMouse'] for map in ['LeftMouse', 'RightMouse']
exec 'inoremap <silent> <Plug>delimitMateM'.map.' <C-R>=delimitMate#Finish()<CR><'.map.'>' exec 'inoremap <silent> <Plug>delimitMateM'.map.' <C-R>=delimitMate#Finish(1)<CR><'.map.'>'
if !hasmapto('<Plug>delimitMate'.map, 'i') if !hasmapto('<Plug>delimitMate'.map, 'i')
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMateM'.map exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMateM'.map
endif endif
endfor endfor
" Map away! " Jump over next delimiters
if !hasmapto('<Plug>delimitMateDel', 'i') inoremap <buffer> <Plug>delimitMateJumpMany <C-R>=len(b:_l_delimitMate_buffer) ? delimitMate#Finish(0) : delimitMate#JumpMany()<CR>
silent! imap <unique> <buffer> <Del> <Plug>delimitMateDel if !hasmapto('<Plug>delimitMateJumpMany')
endif imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany
if !hasmapto('<Plug>delimitMateBS','i')
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
endif
if !hasmapto('<Plug>delimitMateS-BS','i')
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
endif
if b:_l_delimitMate_expand_cr != 0 && !hasmapto('<Plug>delimitMateCR', 'i')
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
endif
if b:_l_delimitMate_expand_space != 0 && !hasmapto('<Plug>delimitMateSpace', 'i')
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
endif
if b:_l_delimitMate_tab2exit && !hasmapto('<Plug>delimitMateS-Tab', 'i')
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
endif endif
" The following simply creates an ambiguous mapping so vim fully processes " The following simply creates an ambiguous mapping so vim fully processes
" the escape sequence for terminal keys, see 'ttimeout' for a rough " the escape sequence for terminal keys, see 'ttimeout' for a rough
" explanation, this just forces it to work " explanation, this just forces it to work
@@ -440,8 +414,9 @@ augroup delimitMate
" Run on new buffers. " Run on new buffers.
autocmd BufNewFile,BufRead,BufEnter * autocmd BufNewFile,BufRead,BufEnter *
\ if !exists("b:loaded_delimitMate") | \ if !exists('b:delimitMate_was_here') |
\ call <SID>DelimitMateDo() | \ call <SID>DelimitMateDo() |
\ let b:delimitMate_was_here = 1 |
\ endif \ endif
" Flush the char buffer: " Flush the char buffer: