Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Bash Vi mode (aka set -o vi). Still I miss the Ctrl-A shortcut from Emacs mode, which is very handy. Many times I'm retrieving the last command and append an echo to the beginning of the line in order to save it to a file.

Is there a convenient way to jump to the start of the line while in insert mode?

And by convenient I mean that it's accessible by two sensible buttons shortcut. So Esc,I is not good enough, because Esc is too far, and Ctrl+[,I is not good because I need to type three consecutive letters, not sleek enough.

share|improve this question
If Esc is too far, why are you using vi mode at all? Why don't you stick with emacs mode? – glenn jackman Feb 15 '11 at 14:04
If you are a vi fan, I highly suggest binding your Caps Lock key to ESC. – mattdm Feb 15 '11 at 14:30
@mattdm, by who? by X? by bash? Unfortunately, I already have Capslock bound to the keyboard layout switch, and it's hard to find another reachable key... – Elazar Leibovich Feb 15 '11 at 18:41
Yeah, by X. If you use the keyboard layout (altgr?) switch a lot, that might be unavoidable. I use the "menu" key for that, but I really use it only infrequently. – mattdm Feb 15 '11 at 18:48
up vote 1 down vote accepted

Press the Home key if it's not too far. Or bind Ctrl+A:

set -o vi
bind '\C-a:beginning-of-line'
share|improve this answer
I didn't want to walk down the slippery bind slope, since eventually you end up with a .emacs file more complex than the emacs source code, but it's certainly a viable option. – Elazar Leibovich Feb 15 '11 at 9:05

Many times I'm retrieving the last command and append an echo to the beginning of the line in order to save it to a file.

An alternative is:

echo !!
share|improve this answer
Yeah, I know that. But sometimes I don't remember which one of the last 3 commands it was, so I want to see them first on the screen, or change a few parameters. Thanks. – Elazar Leibovich Feb 15 '11 at 9:20
Then do history, then echo !nnn where nnn is the history number. If you know it was the 2nd last command, then echo !-2 also works – glenn jackman Feb 15 '11 at 14:05
@glenn, as I said: (1) I don't remember the exact number, (2) sometimes I need to edit the line lightly. – Elazar Leibovich Feb 15 '11 at 18:41

Your Answer


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.