bash 命令行编辑

Unix like 使用bash敲比较长的命令时,经常需要编辑其中的一部分,如果使用左右箭头一个一个挪,就不方便了,查了一下bash的文档,命令行的编辑功能很强大:


命令行随时都可以敲回车,整个行会作为命令执行,不管光标在什么地方。


最基本的:

C-b
Move back one character. 向后移动一个字符
C-f
Move forward one character.向前移动一个字符
DEL
Delete the character to the left of the cursor.删除左边的字符
C-d
Delete the character underneath the cursor. 删除光标所在的字符
C-_
Undo the last thing that you did. You can undo all the way back to an empty line. 回退

移动命令:

C-a
Move to the start of the line. 到开始
C-e
Move to the end of the line. 到结尾
M-f
Move forward a word. 向前一个字
M-b
Move backward a word.向后一个字
C-l
Clear the screen, reprinting the current line at the top. 清屏,当前命令行到屏幕顶端。

剪贴(内容都到了剪贴板)


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. 从剪贴板里面循环选择粘贴。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值