PLT方案(球拍)

发布于 2024-10-31 14:16:24 字数 43 浏览 1 评论 0原文

有谁知道如何或是否可以在 drScheme/Racket 中自动完成括号

Has anyone got any idea how or if it is possible to carry parentheses auto complete in drScheme/Racket

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

生生漫 2024-11-07 14:16:24

DrRacket 不会自动完成右括号(我假设这就是您所问的问题),但它会插入正确的括号形状 - 因此您可以快速点击 ]]] a几次,直到您关闭正确的水平。

但作为旁注,如果您始终保持括号(各种形状)和双引号等平衡,那么使用任何 sexpr 语言(或实际上任何其他语言)都会更容易。 DrRacket 通过使用 Alt-( 插入一对括号并将光标留在中间,使此操作变得容易。Emacs 也做同样的事情,但 DrRacket 对于方括号、花括号和这种工作方式非常有效,因为您永远不需要计算括号甚至查看突出显示,因为同样适用,因此处理代码也很容易 - 前提是代码是。正确缩进(这意味着括号会淡出到您不自觉地查看的内容)。

DrRacket doesn't auto-complete closing parentheses (which I'm assuming is what you're asking about), but it will insert the correct paren shape -- so you can quickly hit ]]] a few times until you're closing off the right level.

But as a sidenote, it is much easier to work in any sexpr language (or actually any other language) if you keep the parentheses (of all shapes) and double quotes etc balanced at all times. DrRacket makes this easy to do by making Alt-( insert a pair of parens and leaving the cursor in the middle. Emacs does the same too, but DrRacket has similar keys for square brackets, curly braces, and double quotes. This style of work is very effective since you never need to count parens or even look at the highlights. It's also easy for working on code since the same holds then -- provided that the code is indented properly (which means that the parens fade to something you don't look at consciously).

乖乖公主 2024-11-07 14:16:24

我同意 Eli 的观点,即始终保持括号平衡更容易,并且想补充一点,实现内置行为并从那里开始自定义您想要的所有内容很容易。在 DrRacket 中,通过“编辑/按键绑定/添加用户定义的按键绑定”,您可以添加如下所示的文件,该文件将绑定添加到“Control-#”,以在光标处(或当前选择周围(如果有)插入一对括号) 。之后你必须重新启动 DrRacket。

#lang s-exp framework/keybinding-lang
(keybinding "c:#"
        (λ (text evt)
          (define a (send text get-start-position))
          (define b (send text get-end-position))
          (send text insert #\( a)
          (send text insert #\) (+ b 1))
          (send text move-position 'left)))

I agree with Eli that it's easier to keep parens balanced at all times and would like to add that it's easy to implement the builtin behaviour and work from there to customize all you want. In DrRacket via "Edit/Keybindings/Add User-defined keybindings" you could add a file like the following which adds a binding to "Control-#" to insert a pair of parens at the cursor (or around the current selection if any). After that you have to restart DrRacket.

#lang s-exp framework/keybinding-lang
(keybinding "c:#"
        (λ (text evt)
          (define a (send text get-start-position))
          (define b (send text get-end-position))
          (send text insert #\( a)
          (send text insert #\) (+ b 1))
          (send text move-position 'left)))
骷髅 2024-11-07 14:16:24

如果 11 年后有人遇到此问题,请执行以下操作

  1. 转到 Mac 上的首选项可能是 Windows 上的设置

  2. 单击编辑选项卡

  3. 启用自动括号

If there is anyone with this problem 11 years later, do the following

  1. Go to preferences on Mac might be settings on Windows

  2. Click on the editing tab

  3. Enable automatic parenthesis

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文