微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

我正在使用Mac.

更新

将以下行添加到接受的答案中以获取ctrl- {a,e}.可以在jline2 repo jline2 repo at GitHub中找到更大的keybindings文件.

# 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

UPDATE2

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

解决方法

这是一个非常小的键绑定属性文件,包括你想要的^ 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上查找存在哪些键绑定,并尝试:来自Scala的键绑定以查看认值(但它不会反映您的实际键绑定).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐