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

时间:2012-09-08 21:11:45

标签: bash command-line

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

4 个答案:

答案 0 :(得分:63)

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

Julia on Bash

答案 1 :(得分:9)

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

与bash相反,不会削减;它只是删除它们。

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

答案 2 :(得分:3)

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

答案 3 :(得分:-2)

Ctrl + x退格清除光标当前位置之前的所有条目