在bash命令行中,如何删除光标前的所有字母?

qaz*_*wsx 38 bash command-line

在bash命令行中,如何删除光标前的所有字母?我知道Ctrl-k会在光标后删除所有内容.

May*_*ura 67

Ctrl-u - Cut everything before the cursor


其他Bash快捷方式,

  • 按Ctrl-A Move cursor to beginning of line
  • CTRL-E Move cursor to end of line
  • 按Ctrl-B Move cursor back one word
  • CTRL-F Move cursor forward one word
  • CTRL-W Cut the last word
  • 按Ctrl-K Cut everything after the cursor
  • CTRL-Y Paste the last thing to be cut
  • 按Ctrl-_ Undo

并通过bash shell的手册页发现更多信息: man bash

额外的bash命令行快捷方式备忘单:http://www.bigsmoke.us/readline/shortcuts

请参阅此处的文档:http://www.gnu.org/software/bash/manual/bashref.html#Commands-For-Killing

必要条件:通过Julia的漫画了解有关Bash,Linux和Tech的更多信息:https://twitter.com/b0rk/media

朱莉娅在巴什

  • 在我的系统上ctrl-b和ctrl -f移动一个字符. (4认同)
  • 知道 zsh 相当于 Ctrl+u 是什么吗? (3认同)
  • 在 zsh 中,Alt+w 清除光标之前的所有字符。 (2认同)
  • @qazwsx 至少对于其中的一部分,GNU readline 是相关软件,由 GNU bash 维护者维护,并与之同步。请参阅 https://tiswww.case.edu/php/chet/readline/rluserman.html 。另外“man 3 readline”也充满了异国情调。 (2认同)

xjc*_*jcl 10

zsh中,Alt+ w清除光标前的所有字符.

与bash相比,这不会削减它们; 它只是删除它们.

这适用于zsh的Emacs模式(默认设置),而不适用于Vi模式.


mjg*_*py3 6

热键Ctrl+U应该可以为您完成此操作。