在 linux 终端中允许换行的快捷方式是什么?

What is the shortcut to allow new lines in linux terminal?

我正在寻找允许在终端中编写多行命令的快捷方式。
我知道它存在,我用过很多次,但我记不住它们,而且我在 google...

中找不到它们

它的行为:
一旦在一行的中间,它将“删除”正确的部分,当我们按下 Enter 按钮时,它不会执行命令,而是转到一个新行(如果我没记错的话,以 '>' 开头).
完成后,我们按第二个快捷键,它会粘贴之前删除的部分,回车键行为恢复为原始状态。

(我以为是Ctrl+j / ctrl+f之类的,其实不是,我也试了很多组合都没成功)

希望你记得他们,你会让我开心。谢谢!

编辑以便更好地理解:

在这样的命令中(调用 ros 服务,提供参数):

rosservice call /operatorshift/updateProgramSteps "category: ''
name: ''
steps:
- command: ''
  args: ''
othersarg ''" 

步骤参数是一个数组,我想提供不止一个步骤,而不删除和重写下一行。
行为如下:
我将光标移动到第 5 行的末尾 (args: '' [HERE]),然后按下第一个快捷键。该命令如下所示:

rosservice call /operatorshift/updateProgramSteps "category: ''
name: ''
steps:
- command: ''
  args: ''  

然后我按“enter”,不是为了执行命令,而是为了添加一个新行(并且“>”字符出现在我的光标左侧,而不是我的计算机名称)。我可以写我的另一个“步骤”,如果我愿意,可以多次按“enter”,所以我的终端看起来像这样:

rosservice call /operatorshift/updateProgramSteps "category: ''
name: ''
steps:
- command: ''
  args: ''  
> - command: 'example'
> args: ''
>  

然后我完成了此命令的编辑,因此我按了第二个快捷方式,检索第一个已删除的内容,“enter”键获得其默认行为(执行命令)

rosservice call /operatorshift/updateProgramSteps "category: ''
name: ''
steps:
- command: ''
  args: ''  
> - command: 'example'
> args: ''
othersarg ''" 

(不确定按第二个快捷键后“>”是否留在屏幕上)

我记得在 Ubuntu 14.04 和 16.04 上使用它,使用默认 shell,无需安装特殊包。

只需输入“\”,当您按下回车键时,您提到的“>”符号就会出现

难道是heredoc

$ cat << EOF
> $ Working dir "$PWD" `pwd`
> EOF
$ Working dir "/home/user" /home/user

遗憾的是,我认为最简单的解决方案是使用 bash 的 edit-and-execute-command 功能;来自手册:

edit-and-execute-command (C-xC-e)

Invoke an editor on the current command line, and execute the result as shell commands. Bash attempts to invoke $VISUAL, $EDITOR, and emacs as the editor, in that order.

如果您在 vi 模式下使用 bash,您只需在普通模式下按 v 即可调用它。

这将在由 $VISUAL$EDITOR 环境变量设置的编辑器中打开您的命令。