Let's share the magic of set -o vi

I just want to share this with the community because I think for some people could be usefull.

If in your terminal you type

set -o vi

This will make your shell capable of using the vi modes while you are writing and editing your commands. If you want to change of mode you just press the escape key, and then press the mode (i for insert, v for [Visual I think, but you know]), and then you can use your vi (So almost vim) keybindings in your terminal. It works in bash and in many others shells. I found this useful when I’m working with browsers terminals. If you know, for many browser pressing Ctrl + some arrow key, and Alt + some arrow key, activates some hotkeys in the browser. My worst nightmare is like pressing Ctrl + ← [Arrow Key] and then go back to the previous webpage in my certification exam. Or pressing the reload webpage [Ctrl + r] not in the web browser terminal, this will reload your webpage. This could be problematic, for example if you are using ctrl + r in your shell to try to search for previous command that you had typed, in order to gain time, and by accident you reload your webpage :upside_down_face:. I found this case very annoying, but if you use the vi mode in your shell, you just need to click with your mouse in your terminal, and those cases will never happend, until you click outside of your terminal again.

So if you are a vim user, or you just want to get out of the worry pressing the ctrl buttom in your browser, you can use this mode in your shell.

Have a nice day.