vi mode inside your shell

Posted in Tips and Tricks

For as long as I can remember I’ve used vim (or vi) as my editor of choice when on Linux or UNIX systems. I’ve also used bash as my shell, except in circumstances where it wasn’t available. We’ve been using Macs for a long time now, and one of the things that I only recently learnt was that you can use CTRL-a to take you to the beginning of a line in a terminal. This meant I no longer leant on the left arrow key to get me back to the beginning of a long command.

I use screen to maintain remote, active connections to our various servers, and with my setup the CTRL-a trick didn’t work. I’ve just found that setting vi mode in bash will allow me to hit ESC then shift-I and take me to the beginning of a line. ESC engages vi mode, and you can navigate around the command as you would inside vi. For example, shift-I or 0 takes you to the start of the line, shift-a or $ to the end and h, l, k and j act as cursor keys.

You can engage vi mode by executing the following code, or adding it to your ~/.profile (or any other dot file that is executed upon login).

set -o vi

I always like finding new shortcuts, even if there’s some minor annoyance at my former lack of awareness. It’s like how we discovered syntax highlighting in vim after completing our uni degrees… very bittersweet.

No Comments

No comments have been left yet, be the first.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Twitter

Great web stats at @petrescue , the driving force behind the rebuild of their systems by @frontiergroup . http://t.co/MTvfoxnU

@frontiergroup about 2 weeks ago #

Search Posts

Featured Posts

Categories

Archives

View more archives