匹配大括号在Emacs [英] Matching braces in Emacs

查看:294
本文介绍了匹配大括号在Emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GNU Emacs中,有一个功能来突出显示具有相同颜色的代码中的匹配括号。

In GNU Emacs there is a feature to highlight matching brackets in code with the same colour.

但是,当括号所包含的代码真的很长,几个嵌套的if's for ...等等,那么这个功能并不真正有用,因为其中一个括号不可见。

However when the code which the brackets enclose is really long with several nested if's for's etc. then this feature is not really useful since one of the brackets will not be visible.

说我有以下,

for(int i=0; i< N; ++i)
 {
  /*Long code*/

 } 

如果我的光标在} 括号上,我想要一些功能,让我跳转/看到 {大括号,然后,如果满意,请回到} 未来编码。

If my cursor is on the } brace I would like to have some feature which will enable me to jump / see the { brace, and then , if satisfied, come back to the } brace for any future coding.

Emacs中有可能吗?

Is this possible in Emacs?

推荐答案

这实际上是一个非常标准的绑定: CMf CMb 默认返回和转发。在大多数模式中,您将向前转到匹配的大括号,而$ code> C-M-b 将使您向后退到匹配的大括号。这也适用于像报价这样的事情,几乎一样。

This is actually a very standard binding: C-M-f and C-M-b to go back and forwards by default. In most modes C-M-f will take you forwards to the matching brace and C-M-b will take you backwards to the matching brace. This also works for things like quotes, pretty much the same way.

如果您已经使用 Cf Cb 导航。 (如果没有,你应该)。他们就像向前和向后移动一个字符被提升到通过表达式移动(这取决于模式)。

These bindings are easy to remember if you already use C-f and C-b for navigation. (If you don't, you should.) They're just like moving forward and backwards by a character lifted to moving by expression (which depends on mode).

这篇关于匹配大括号在Emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆