本文介绍了Emacs键入框架对插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中,编辑Java代码,如果我键入一个开放式,我得到一对括号。如果我然后穿过第二个括号,它不会插入一个附加的括号。如何在emacs中获得这些?

In Eclipse, editing Java code, if I type an open-paren, I get a pair of parens. If I then "type through" the second paren, it does not insert an additional paren. How do I get that in emacs?

Eclipse编辑器足够聪明,当我键入close-paren时,我刚刚完成了我开始的工作。光标前进过去。如果我输入一个分号,同样的事情:它只是覆盖过去的分号,我不会得到其中的两个。

The Eclipse editor is smart enough to know, when I type the close-paren, that I am just finishing what I started. The cursor advances past the close paren. If I then type a semicolon, same thing: it just overwrites past the semicolon, and I don't get two of them.

在emacs中,在java模式或csharp模式下,如果我将open-paren绑定到skeleton-pair-insert-maybe,我可以得到一个开放的实体对,这是好的。但是,如果我穿过紧密的括号,我得到两个紧密的括号。

In emacs, in java-mode, or csharp-mode if I bind open-paren to skeleton-pair-insert-maybe, I get an open-close paren pair, which is good. But then if I "type through" the close paren, I get two close-parens.

有没有办法教导emacs在一个紧接在前的骨架对插入之后不插入关闭括号?如果可能的话,一些类似的情报怎么样才能避免分号加倍?

Is there a way to teach emacs to not insert the close paren after an immediately preceding skeleton-pair-insert-maybe? And if that is possible, what about some similar intelligence to avoid doubling the semicolon?

我问过括号,但同样适用于双引号,大括号,方括号等。

I'm asking about parens, but the same applies to double-quotes, curly braces, square brackets, etc. Anything inserted with skeleton-pair-insert-maybe.

推荐答案

展示了如何做你想要的。作为奖励,它还显示如何设置它,以便如果您在开始char后立即退格,它也将删除光标后的关闭字符。

This post shows how to do what you want. As a bonus it also shows how to set it up so that if you immediately backspace after the opening char, it will also delete the closing char after the cursor.

更新:

自从我发布了这个答案之后,我发现了,这是一个非常完美的系统,用于此用例。我一直在使用它很多,并喜欢它。

Since I posted this answer, I've discovered Autopair which is a pretty much perfect system for this use case. I've been using it a lot and loving it.

这篇关于Emacs键入框架对插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 11:57