Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

Configuring keys as additional quotess #206

Open leeren opened 9 years ago

leeren commented 9 years ago

I put the following line in my .vimrc to use autocompleting dollar signs when writing in LaTeX:

au FileType tex let b:delimitMate_quotes = "\" ' $"

This works great, but now within coupled dollar signs for some reason the autocompleting parentheses no longer works! It works perfectly outside of paired dollar signs but not within them. Any ideas?

samhaney commented 9 years ago

I'm having the same problem, but it only happens with the cursor right at the ending quote. So, typing ( with the cursor (specified by |) as $|$ inserts $(|$ and doing the same with $| $ inserts $(|) $

Is this the correct behavior? Is there some setting which will allow automatic insertion of delimiters even when the cursor is just before the end of the quote?

jfab20 commented 3 years ago

I think this is the correct behaviour, you can read in :help delimitMate this:

                                              *'delimitMate_smart_matchpairs'*
                                            *'b:delimitMate_smart_matchpairs'*
Values: Regexp                                                               ~
Default: '^\%(\w\|\!\|[£$]\|[^[:space:][:punct:]]\)'                                ~

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\|\$\)'
jfab20 commented 3 years ago

You can add this to get allow expansion before $: (I just deleted the $ character in the default regex)

au FileType tex let b:delimitMate_smart_matchpairs='^\%(\w\|\!\|[£]\|[^[:space:][:punct:]]\)'