Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have seen many developers using this command to set the option to vi. I never understood the real use of this?

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

share|improve this question

3 Answers

up vote 11 down vote accepted

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...


1. Assuming, of course, that you use Emacs or Vi/m as your editor.
2. Or, more accurately, a subset thereof...

share|improve this answer

I'm not sure if there is a direct advantage. I've been a vi user for more than 20 years. I'm also a screen user for even longer, and of other programs that use vi keys. It's natural for me to prefer to set "vi" mode in bash. But I also work on hundreds of servers in my job, most are set to the default "emacs" mode. So I need to use both modes. But it is really just a matter of preference.

share|improve this answer
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across. – jw013 Jan 31 '12 at 20:52

The main advantage is modal editing of your command line. If you're familiar with Vim and likes its philosophy the benefits must be obvious. If you are experienced with it, your finger's muscle memory will make you edit your bash commands in lightning speeds.

NB: If you don't like modal editing, you should still learn to take advantage of the (default) emacs-mode. Here are some nifty keyboard shortcuts that will work on any process with readline, like bash.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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