首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法在Scala的REPL中使用ctrl作为前向删除?

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

Stack Overflow用户
提问于 2011-03-21 23:12:31
回答 2查看 1.3K关注 0票数 4

因此,在Scala中,我可以使用ctrl-{p,n,a,e}来执行行的前面-、下一个、开头和结尾。但是,如果我不能使用ctrl转发-删除,我很快就会发疯。

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

我用的是Mac。

更新

将下列行添加到接受的答案中,以获得ctrl-{a,e}。在jline2 repo jline2回购在GitHub中可以找到更大的键绑定文件堪萨斯州。

代码语言:javascript
复制
# 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

我刚刚安装了Scala2.9.0.final,我可以确认ctrl现在正在正常工作。除非它在终止shell时是空行,否则它是向前删除。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-03-22 00:43:26

下面是一个非常小的密钥绑定属性文件,包括您想要的^D

代码语言:javascript
复制
# 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:

代码语言:javascript
复制
scala -Djline.keybindings=/path/to/keybindings.properties

或者通过JAVA_OPTS传递。您必须在Internet上查找存在哪些键绑定,并尝试使用Scala的:keybindings来查看缺省值(不过,它不会反映实际的键绑定)。

票数 4
EN

Stack Overflow用户

发布于 2011-03-21 23:56:31

在Scala2.9的REPL中,有一个新的键绑定命令。这表明:

代码语言:javascript
复制
scala> :keybindings
Reading jline properties for default key bindings.
Accuracy not guaranteed: treat this as a guideline only.

  1 CTRL-A: move to the beginning of the line
  2 CTRL-B: move to the previous character
  4 CTRL-D: close out the input stream
  5 CTRL-E: move the cursor to the end of the line
  6 CTRL-F: move to the next character
  7 CTRL-G: abort
  8 BACKSPACE, CTRL-H: delete the previous character 8 is the ASCII code for backspace and therefor deleting the previous character
  9 TAB, CTRL-I: signal that console completion should be attempted
 10 CTRL-J, CTRL-M: newline
 11 CTRL-K: erase the current line
 12 CTRL-L: clear screen
 13 ENTER: newline
 14 CTRL-N: scroll to the next element in the history buffer
 15 CTRL-O: move to the previous word
 16 CTRL-P: scroll to the previous element in the history buffer
 18 CTRL-R: redraw the current line
 21 CTRL-U: delete all the characters before the cursor position
 22 CTRL-V: paste the contents of the clipboard (useful for Windows terminal)
 23 CTRL-W: delete the word directly before the cursor
127 DELETE, CTRL-?: delete the next character 127 is the ASCII code for delete

在macbook笔记本电脑上,DELETE可以通过Fn + BACKSPACE访问。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5384852

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档