I remember running across this command a while back although I do not remember the command itself. As I remember it, you ran the command, it would create a temp buffer that would then be edited by the default editor (vim) and upon closing the buffer, the command would be executed.


$ <buffer edit command>
~ # Write bash temp script
~ for i in *; do
~     echo $i
~ done
$ file1
$ file2
$ file3
$ ...

Does anyone know what this command is? It is like writing a bash script in vim only without saving the file and just running it.

  • 3
    Are you thinking of fc, or was it a standalone command? – Michael Homer Jul 30 '18 at 20:13

You want to bind some key combo to edit-and-execute-command. I use:

bind '"\C-e": edit-and-execute-command'

in my ~/.bashrc. When I hit Ctrl-e, it invokes $EDITOR and lets me edit the command. When I save and quit, it executes the edited command.

  • 2
    Thats it, it was not a command but a shortcut thank you. – Drew Jul 30 '18 at 20:18
  • 2
    @Drew FYI, the default key combination for this is C-x C-e (that is, hold Ctrl and then first hit x and then e). – Ventero Jul 30 '18 at 23:03

If you run set -o vi (or have it in your ~/.bashrc), then pressing v in normal mode (i.e., press Esc and then v) will bring up a buffer as you describe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.