Sunday, November 25, 2012

Utilizing your Bash Shell with VIM

Bash shell has a score of features. Mostly they go unused. It has some very nice features that let you save time and be more productive, allowing you to maneuver intricately and imaginatively.

The Best One is:

$ set -o vi

This sets vi as a command line editor in the Bash environment. Press the escape key and you are in the vim mode. You can use all the vim single line commands to edit the command line. Press the 'v' key while in vim mode and you can edit the command straight in a full fledged VIM editor. Isn't it great!


To search a command:
Press esc and then press '/' i.e. slash, and  type some characters to search. To repeat the search in forward and backward directions, guess what.... the 'n' and 'N' keys do the same job here too. Use 'n' for backward searches and 'N' for the opposite direction.

$ /<partial cmd name>

This sequence searches the command history (bottom up) and produces the most recently used cmd matching the <partial cmd name>. Really a good feature. Now when you have the old command line, you can edit it using the features of vim.

No comments:

Post a Comment