Aman Jain
Aman Jain

Reputation: 11317

How do I get Vim to highlight matching parenthesis?

When I browse code in Vim, I need to see opening and closing parenthesis/ brackets, and pressing % seems unproductive.

I tried :set showmatch, but it makes the cursor jump back and forth when you type in a bracket. But what to do if I am browsing already written code?

Upvotes: 44

Views: 80915

Answers (4)

Bruce Zhang
Bruce Zhang

Reputation: 115

An upgrade of vim from version 6.3 to 8.0 might swap/upgrade the code file that manages this MatchParen functionality under /usr/share/vim/vim80/plugin/matchparen.vim

The function to begin investigating a vim failure for highlighting matching brackets is called: Highlight_Matching_Pair(). Do an echo and a sleep and step through the code until matchaddpos(...) runs.

Upvotes: 1

jcoby
jcoby

Reputation: 4260

set showmatch is your best bet. you can also use the % command to jump between matching parenthesis, braces, brackets, quotes, etc.

Upvotes: 43

Grissiom
Grissiom

Reputation: 12073

Maybe what you want is this plugin:

http://www.vim.org/scripts/script.php?script_id=350

Upvotes: 0

Harley Holcombe
Harley Holcombe

Reputation: 182096

DoMatchParen

in your .vimrc file

or

:DoMatchParen

within vim itself.

Edit: This comes from the pi_paren plugin (which is a standard plugin).

Upvotes: 48

Related Questions