mirror of
https://github.com/Raimondi/delimitMate.git
synced 2026-05-18 06:19:54 +08:00
- Shift + Backspace inside an empty pair will delete the closing delimiter.
This commit is contained in:
@@ -13,3 +13,7 @@ vimball: install
|
|||||||
echo doc/${PLUGIN}.txt > vimball.txt
|
echo doc/${PLUGIN}.txt > vimball.txt
|
||||||
echo plugin/${PLUGIN}.vim >> vimball.txt
|
echo plugin/${PLUGIN}.vim >> vimball.txt
|
||||||
vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q'
|
vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q'
|
||||||
|
|
||||||
|
gzip: vimball
|
||||||
|
gzip -f ${PLUGIN}.vba
|
||||||
|
|
||||||
|
|||||||
+11
-9
@@ -228,18 +228,17 @@ function! s:QuoteDelim(char) "{{{1
|
|||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.')
|
let col = col('.')
|
||||||
if line[col - 2] == "\\"
|
if line[col - 2] == "\\"
|
||||||
" Seems like a escaped character, insert a single quotation mark.
|
" Seems like a escaped character, insert one quotation mark.
|
||||||
return a:char
|
|
||||||
elseif line[col - 2] == a:char && line[col - 1 ] != a:char
|
|
||||||
" Seems like we have an unbalanced quote, insert a single
|
|
||||||
" quotation mark.
|
|
||||||
return a:char."\<Left>"
|
|
||||||
elseif a:char == "'" && line[col -2 ] =~ '[a-zA-Z0-9]'
|
|
||||||
" Seems like we follow a word, insert an apostrophe.
|
|
||||||
return a:char
|
return a:char
|
||||||
elseif line[col - 1] == a:char
|
elseif line[col - 1] == a:char
|
||||||
" Get out of the string.
|
" Get out of the string.
|
||||||
return "\<Right>"
|
return "\<Right>"
|
||||||
|
elseif line[col - 2] == a:char && line[col - 1 ] != a:char
|
||||||
|
" Seems like we have an unbalanced quote, insert one quotation mark.
|
||||||
|
return a:char."\<Left>"
|
||||||
|
elseif a:char == "'" && line[col -2 ] =~ '[a-zA-Z0-9]'
|
||||||
|
" Seems like we follow a word, insert an apostrophe.
|
||||||
|
return a:char
|
||||||
else
|
else
|
||||||
" Insert a pair and jump to the middle.
|
" Insert a pair and jump to the middle.
|
||||||
return a:char.a:char."\<Left>"
|
return a:char.a:char."\<Left>"
|
||||||
@@ -299,7 +298,7 @@ function! s:AutoClose() "{{{1
|
|||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>ClosePair("\' . delim . '")<CR>'
|
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>ClosePair("\' . delim . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Try to fix the use of apostrophes:
|
" Try to fix the use of apostrophes (de-activated by default):
|
||||||
" inoremap <buffer> n't n't
|
" inoremap <buffer> n't n't
|
||||||
for map in s:apostrophes
|
for map in s:apostrophes
|
||||||
exec "inoremap <buffer> " . map . " " . map
|
exec "inoremap <buffer> " . map . " " . map
|
||||||
@@ -373,6 +372,9 @@ function! s:ExtraMappings() "{{{1
|
|||||||
" If pair is empty, delete both delimiters:
|
" If pair is empty, delete both delimiters:
|
||||||
inoremap <buffer> <expr> <BS> <SID>WithinEmptyPair() ? "\<Right>\<BS>\<BS>" : "\<BS>"
|
inoremap <buffer> <expr> <BS> <SID>WithinEmptyPair() ? "\<Right>\<BS>\<BS>" : "\<BS>"
|
||||||
|
|
||||||
|
" If pair is empty, delete closing delimiter:
|
||||||
|
inoremap <buffer> <expr> <S-BS> <SID>WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
||||||
|
|
||||||
" Expand return if inside an empty pair:
|
" Expand return if inside an empty pair:
|
||||||
if exists("b:delimitMate_expand_cr") || exists("g:delimitMate_expand_cr")
|
if exists("b:delimitMate_expand_cr") || exists("g:delimitMate_expand_cr")
|
||||||
inoremap <buffer> <CR> <C-R>=<SID>ExpandReturn()<CR>
|
inoremap <buffer> <CR> <C-R>=<SID>ExpandReturn()<CR>
|
||||||
|
|||||||
Reference in New Issue
Block a user