views:

74

answers:

3

With the syntax highlighting in vim, I get the handy feature where the matching paren or bracket will be highlighted when I put the cursor over it. Is it possible to do the same thing for quotes?

A: 

VIM already highlights quoted text in a different color, so you can easily identify strings. Do you really need it to match quotes when the whole string is already highlighted?

Justin Ethier
"Need"? no. "Would like"? yes.
Jed Daniels
Fair enough, but I was trying to get at: "Why would you want to match quotes when vim already highlights the whole string for you". Can you give us a use case?
Justin Ethier
+1  A: 

The problem with quotes is that they are symmetrical. It would be very hard to determine which quotes belong with each other.

For instance: "Which \"quotes\" go with each other in this statement?"

This has been discussed on the vim mailing lists a few times, as well as in the bug trackers of a few of the auto-delimiter type plugins. In every case that I've seen, it's been decided that this is better left as is.

Randy Morris
Vim's quote text-objects (http://vimdoc.sourceforge.net/htmldoc/motion.html#aquote) already have the smarts to deal with that. The problem is that `searchpairpos()`, which is what the MatchParen plugin uses to highlight parens, isn't able to find matching quotes.
jamessan
Clearly the vim folks have figured this out well enough to highlight the quoted text properly, so I can't see why it would be any harder to highlight the quote itself when the cursor is over it. And, wouldn't brackets have the same issue? E.g. `{Which \{bracket\} matches the first bracket?}`
Jed Daniels
A: 

While not eloquent, one workaround is to select everything inside of matching quotes. You can do this by using the command:

vi"

This will select everything in-between the quotes. However, you won't get proper results with nested quotes as it will match the first found ".

j0rd4n