Unix like 使用bash敲比较长的命令时,经常需要编辑其中的一部分,如果使用左右箭头一个一个挪,就不方便了,查了一下bash的文档,命令行的编辑功能很强大:
命令行随时都可以敲回车,整个行会作为命令执行,不管光标在什么地方。
最基本的:
C-b移动命令:
剪贴(内容都到了剪贴板)
c-k
Kill the text from the current cursor position to the end of the line. 剪贴光标处到行尾
M-d
Kill from the cursor to the end of the current word, or if between words, to the end of the next word. 剪贴光标处到字尾
-
M-DEL
- Kill from the cursor the start of the previous word, or if between words, to the start of the previous word. 剪贴光标处到上一个字尾 C-w
- Kill from the cursor to the previous whitespace. This is different than M-DEL because the word boundaries differ. 剪贴光标处到上一个空白字符。
粘贴:
-
C-y
- Yank the most recently killed text back into the buffer at the cursor. 最新的粘贴板内容到光标处。 M-y
- Rotate the kill-ring, and yank the new top. You can only do this if the prior command is C-y or M-y. 从剪贴板里面循环选择粘贴。