开发者

How to find if else blocks fast in Emacs

开发者 https://www.devze.com 2023-01-09 07:07 出处:网络
If I have code that has a lot of if/then/else conditions like so: if () { if () { } else { } } else { if () {

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号