mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-08 05:34:45 +08:00
Smart quotes consider balanced quotes on current line. Closes #94.
This commit is contained in:
@@ -261,8 +261,11 @@ function! delimitMate#IsSmartQuote(char) "{{{
|
|||||||
let valid_char_re = '\w\|[^[:punct:][:space:]]'
|
let valid_char_re = '\w\|[^[:punct:][:space:]]'
|
||||||
let word_before = char_before =~ valid_char_re
|
let word_before = char_before =~ valid_char_re
|
||||||
let word_at = char_at =~ valid_char_re
|
let word_at = char_at =~ valid_char_re
|
||||||
let escaped = delimitMate#CursorIdx() >= 1 && delimitMate#GetCharFromCursor(-1) == '\'
|
let escaped = delimitMate#CursorIdx() >= 1
|
||||||
let result = word_before || escaped || word_at
|
\ && delimitMate#GetCharFromCursor(-1) == '\'
|
||||||
|
let noescaped = substitute(getline('.'), '\\.', '', 'g')
|
||||||
|
let even = !(count(split(noescaped, '\zs'), a:char) % 2)
|
||||||
|
let result = word_before || escaped || word_at || !even
|
||||||
return result
|
return result
|
||||||
endfunction "delimitMate#SmartQuote }}}
|
endfunction "delimitMate#SmartQuote }}}
|
||||||
|
|
||||||
|
|||||||
@@ -291,9 +291,9 @@ e.g.: >
|
|||||||
Values: String. ~
|
Values: String. ~
|
||||||
Default: Empty. ~
|
Default: Empty. ~
|
||||||
|
|
||||||
The contents of this string will be inserted after the closing matchpair when
|
The contents of this string will be inserted after the closing matchpair or
|
||||||
the opening matchapair is inserted at the end of the line. This feature only
|
quote when the respective opening matchapair or quote is inserted at the end
|
||||||
works if the eol marker was inserted on the current insert session.
|
of the line.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
au FileType c,perl let b:delimitMate_eol_marker = ";"
|
au FileType c,perl let b:delimitMate_eol_marker = ";"
|
||||||
<
|
<
|
||||||
@@ -425,11 +425,11 @@ e.g. typing at the "|": >
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.4 SMART QUOTES *delimitMateSmartQuotes*
|
3.4 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 "\", following or
|
||||||
preceding a keyword character. This should cover closing quotes after a
|
preceding a keyword character, or when the number of quotes in the current
|
||||||
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
line is odd. This should cover closing quotes after a string, opening quotes
|
||||||
for apostrophes, this feature can be disabled setting the option
|
before a string, escaped quotes and apostrophes. Except for apostrophes, this
|
||||||
|'delimitMate_smart_quotes'| to 0.
|
feature can be disabled setting the option |'delimitMate_smart_quotes'| to 0.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
|||||||
@@ -38,3 +38,5 @@ set cpo=ces$
|
|||||||
"('test'x" "('test'x)"
|
"('test'x" "('test'x)"
|
||||||
# Duplicate whole line when inserting quote at bol #105
|
# Duplicate whole line when inserting quote at bol #105
|
||||||
"}\<Home>'" "''}"
|
"}\<Home>'" "''}"
|
||||||
|
"'\<Del>abc '" "'abc '"
|
||||||
|
"''abc '" "''abc ''"
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ sub foo {
|
|||||||
call setline(1, '"{bracketed}')
|
call setline(1, '"{bracketed}')
|
||||||
normal A"x
|
normal A"x
|
||||||
================================================================================
|
================================================================================
|
||||||
"{bracketed}"x"
|
"{bracketed}"x
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
|
# Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
|
||||||
# with :normal
|
# with :normal
|
||||||
|
|||||||
Reference in New Issue
Block a user