sorgenkind
sorgenkind

Reputation: 301

vim fails to match symbols in php properly

<?php
    $foo->bar();
?>

If you press % while the cursor is on the first '<' the cursor moves to the next '>' instead of the one in the last line.

Any chance to fix this?

edit:

my vim version:

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:09:45)

i also have matchit.vim installed for the case that it matters.

Upvotes: 0

Views: 72

Answers (1)

jamessan
jamessan

Reputation: 42667

You want to use the matchit plugin. That allows smarter matching of tokens based on the given filetype being edited. :help matchit-install will tell you how you can setup matchit to be sourced on startup so it's available when you're editing.

Once it's setup, when you edit a PHP file, a map will be created for % that runs matchit's functionality. It also defines various buffer-local variables (such as b:match_words) which can be tailored to determine how % behaves -- recognized tokens, how they're related to each other, etc.

Upvotes: 1

Related Questions