Reputation: 23
I want to know declaration of open bracket when focused close bracket.(ex. if (...) ).
I know emacs, vscode, vim are has goto declaration function. But, they needs 1 action(type M-.(emacs),F12(vscode),%(vim)). I don't want to type some key each time. So, I want to know declaration of bracket with 0-action.
I don't care how displays in declaration(pop-up, mini buffer, status bar)
Background: I'm in fixing legacy code. The code is too much nested with ifs and fors and whiles. By much nested, end of code are many continus close bracket(}) like below.
for (var item in list){
if (cond1) {
...
while( cond2 ) {
...
if (cond3) {
...
} else {
...
}
}
}
list.append(item)
}
}
I usually mistake cond2 and cond3, created bugs, don't show log messages, and spent much time.
This question was translated by google translator. so, if you couldn't recognise this, please comment.
Upvotes: 0
Views: 150
Reputation: 4673
To quote Mass:
Yes- the plugin match-up has this feature: https://github.com/andymass/vim-matchup
Using the option
let g:matchup_matchparen_offscreen = { 'method': 'popup' }
There is also the ability to show the match in the statusline (the default):
let g:matchup_matchparen_offscreen = { 'method': 'status' }`
Upvotes: 1
Reputation: 196496
When your cursor is on a bracket, the other one is highlighted automatically if you have :help matchparen
enabled.
When your cursor is on a bracket, you can jump to the opening one with :help %
.
Upvotes: 1