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

Different behaviours of `delimitMate_excluded_regions` for Python strings (related with highlight groups) #203

Open Hexcles opened 9 years ago

Hexcles commented 9 years ago

It is really a strange problem I discovered when creating colorschemes. After trying my best to narrow down the problem, I got the following minimum requirements to trigger this issue:

Vim version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 14 2015 20:16:36)
Included patches: 1-580
Compiled by Arch Linux
Huge version with GTK2 GUI.

Vimrc

Create a clean vimrc (and surely install Vundle and delimitMate).

set nocompatible
syntax on
set backspace=2
"start Vundle
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'

"delimitMate (match pairs)
Plugin 'Raimondi/delimitMate'
let delimitMate_excluded_regions = "String"

call vundle#end()
filetype plugin indent on
"end Vundle

Command sequence

vim -u [the above vimrc file] foobar.py

Try input two quotes. The first one will result in a pair of quote. The second one will make the cursor out of the quote, instead of inserting a new quote.

i.e. you will get:

  1. '|'
  2. ''|

Now change the String highlight group from linking to Constant (:hi link String Constant) to a separate group, by assigning whatever attributes:

:hi String term=bold

Now repeat the previous key sequence again. This time the second quote you input will result in a new quote!

i.e.:

  1. '|'
  2. ''|'

The delimitMate_nesting_quotes will also behave differently in the two conditions.