一张图搞明白如何在命令行中快速移动光标
一张图搞明白如何在命令行中快速移动光标
命令解释:
part 1: 光标的移动
(1)Ctrl - A # 移动到行首
(2)Ctrl - E # 移动到行尾
(3)Alt - B # 移动到单词首部
(4)Alt - F # 移动到单词尾首 (ubuntu 1604 的终端下并未起作用)
Esc - F 可以实现“移动到单词尾部”功能(用法:同时按下 Esc + F 键,若想多次执行,只可多次按下,不可按住 Esc 然后连续点击F)
(5)Ctrl - B # 左移一个字符
(6)Ctrl - F # 右移一个字符
part 2: 命令字符的删除
(1)Ctrl - U # 删除(剪切)到行首
(2)Ctrl - K # 删除(剪切)到行尾
(3)Ctrl - W # 删除(剪切)到单词首部
(4)Alt - D # 删除(剪切)到单词尾首
(5)Ctrl + D # 删除当前所在字符
(6)Ctrl + H # 向左删除一个字符
part 3: 粘贴
(1)Ctrl + Y # 粘贴最后一次剪切的字符串
注:(1) 空格和 / 都被当作“单词”的分隔符,这里的“单词” 只是连续的字符,并不是完整的单词。
(2) “删除” 其实也是“剪切”。
也可参考PPT:https://talk.linuxtoy.org/cli-tips/#1
I’m tired of pounding on the arrow keys when moving in the command line, but I keep on forgetting the keyboard shorcuts that would help me move more efficiently, so here’s a simple diagram in a flashcard format for future reference!
I found a useful table with most of those in the How Linux Works book that I’m currently reading, and some more on Stack Overflow.
If you plan on using them, please bear in mind that these keyboard shorcuts depend on quite a number of things: the Unix distribution that you’re using, your shell, your own configuration quirks… so YMMV.
- 原文 / From twitter.com/linuxtoy/status/957225197928525824