Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way that I can change my .vimrc file so that unclosed parenthesis/brackets/braces are highlighted? For instance the following would highlight the parenthesis after the word main:

public static void main(String[] args
{
    System.out.println("Foobar");
}

Or perhaps, have VIM somehow tell me that I have an unclosed parenthesis. It appears that VIM currently shows when you have an unopened parenthesis but not when you have an unclosed one.

share|improve this question
    
This would be nice, though I doubt we will see a solution since the default would be the same next close peren, so the missing one after String[] would be assumed as the one after since VIM doesn't know that's not an argument. –  nerdwaller Feb 2 '13 at 1:35
add comment

1 Answer

up vote 2 down vote accepted

There exists a plugin for vim to do just this. Given this your example code:

public static void main(String[] args
{
    System.out.println("Foobar");
}

Wherever you place your cursor, the closest back mismatched parentheses will be highlighted. The only defect is that it doesn't look ahead, to see if it is matched later. So if you were within the pringln parentheses if would highlight the opening one. It is basically functional and should serve you fine.

It is called vim-matchopen and can be found at https://github.com/arnar/vim-matchopen


If you havn't had expirence installing vim plugins, here is a quick intro for this one. (I am assuming that you are using Linux.)

Go to the download site. If you have git and know how to use it, go ahead. If not then use the download zip button, and extract the downloaded zip to some temporary destination.

Next you need to take the script plugin/matchopen.vim and place it in the directory ~/.vim/plugin. If that directory doesn't exist, create it.

That should be it. Then you will be up and running. Just restart vim.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.