gpt4 book ai didi

scala - 有没有办法在 Scala 的 REPL 中使用 ctrl-d 作为前向删除?

转载 作者:行者123 更新时间:2023-12-05 00:04:45 24 4
gpt4 key购买 nike

所以在 Scala REPL 中,我可以使用 ctrl-{p,n,a,e} 来执行上一行、下一行、行首和行尾。但是,如果我不能使用 ctrl-d 进行前向删除,我很快就会发疯。

是否有可能以某种方式实现这一目标?

我正在使用 Mac。

更新

将以下行添加到接受的答案以获得 ctrl-{a,e}。在 jline2 存储库 jline2 repo at GitHub 中可以找到更大的键绑定(bind)文件。 .

# CTRL-A: move to the beginning of the line
1=MOVE_TO_BEG

# CTRL-E: move the cursor to the end of the line
5=MOVE_TO_END

更新2

我刚刚安装了 Scala 2.9.0.final,我可以确认 ctrl-d 现在可以正常工作。它是正向删除,除非它在终止 shell 时是空行。

最佳答案

这是一个非常小的键绑定(bind)属性文件,包括您想要的 ^D :

# CTRL-B: move to the previous character
2: PREV_CHAR

# CTRL-D: delete the previous character
4: DELETE_NEXT_CHAR

# CTRL-F: move to the next character
6: NEXT_CHAR

# BACKSPACE, CTRL-H: delete the previous character
# 8 is the ASCII code for backspace and therefor
# deleting the previous character
8: DELETE_PREV_CHAR

# TAB, CTRL-I: signal that console completion should be attempted
9: COMPLETE

# CTRL-J, CTRL-M: newline
10: NEWLINE

# ENTER: newline
13: NEWLINE

# CTRL-N: scroll to the next element in the history buffer
14: NEXT_HISTORY

# CTRL-P: scroll to the previous element in the history buffer
16: PREV_HISTORY

# CTRL-V: paste the contents of the clipboard (useful for Windows terminal)
22: PASTE

# DELETE, CTRL-?: delete the previous character
# 127 is the ASCII code for delete
127: DELETE_PREV_CHAR

把它放在一个文件中,然后像这样调用 scala:
scala -Djline.keybindings=/path/to/keybindings.properties

或通过 JAVA_OPTS .您必须在 Internet 上查找存在哪些键绑定(bind),然后尝试 :keybindings从 Scala 查看默认值是什么(但它不会反射(reflect)您的实际键绑定(bind))。

关于scala - 有没有办法在 Scala 的 REPL 中使用 ctrl-d 作为前向删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5384852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com