Wednesday, February 23, 2011

Entering command mode in shells with vi bindings

If you use zsh or bash with vi key bindings, you know that by default the shell is in insert mode.  Every time you need to run some editing command you would first press Esc to enter command mode.  I recently found that just pressing Alt along with the first key in your command will put you in command mode.

For example, if you want to go up in command history, press Alt+k.  That will put you in command mode and take you to the previously run command.  From there on, pressing k will scroll up the command history.  One very useful shortcut I use is Alt+I (which is Alt+Shift+i): this is equivalent to Ctrl+a in Emacs mode or pressing the Home key.

No comments:

Post a Comment