tags:

views:

98

answers:

2

If I have code that has a lot of if/then/else conditions like so:

if () {
if () {

} else {

}
} else {
if () {

} else {

}
}

and there might also be a lot of text inside those conditions. How can I quickly find the outermost if as well as the corresponding else.

+3  A: 

I'd use backward-up-list (bound to C-M-up) to work my way up the nested blocks to the if I'm interested in, then use forward-sexp (bound to C-M-right) when on the left bracket to jump over the block to the else.

scottfrazer
+2  A: 

Try moving by parentheses: M-C-b (back), M-C-f (forward), M-C-n (next), M-C-p. Don't be afraid to just move the point to the top of the buffer and isearch forward. You can also move by defuns and other constructs.

Joel J. Adamson