Tuesday, 11 October 2016

When using bash commands, what help does switching to vi provide?

How to switch to vi mode when editing bash commands?

set -o vi

By setting your readline editing to either emacs (the default) or vi (set -o vi)
you are essentially standardizing your editing commands, across the shell and your editor of choice1.

Thus, if you want to edit a command in the shell you use the same commands2 that you would if you
were in your text editor. This means only having to remember one command syntax and (if that were
 not advantage enough) would probably make your editing in both environments faster and less error prone...

You can further leverage this relationship in vi-mode by pulling up any command from your shell history,
 hitting Escape to enter command mode and then hitting v, which will open your $EDITOR with the command
 loaded for more complex editing with the full power of vim. Once you have finished editing the command
 to your satisfaction, :wq and the command is executed back in your shell.

No comments:

Post a Comment