text editor mode for calling bash command

bash, command, command-line, linux, vi

Solution

See `man bash`:

   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.

Per default bash is configured for emacs mode, hence the emacs like C-xC-e command.

If you really like vi you can also set your bash into vi mode: `set -o vi`. This allows you to do normal line editing the vi way without invoking an explicit editor.

Problem

suppose I want to enter a multiline command via bash I know that I can append \ in the end of the line to enter a new line however is it possible to enter a legitimate "text editor mode" where you don't even have to enter \ and simply press enter would suffice eg..you type in the command into the command line then before entering the parameters you press some magic button which allows you to enter a vi like mode then you enter stuff into the "vi mode" then you exit and then the text you entered in the "vi mode" turns into the parameters of the command then you press enter then the command executes is it possible to do that in bash command line? if so, how do I do it?

Original source