Super User is a question and answer site for computer enthusiasts and power users. 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

Say I have a hundred commands in my shell's history, and now I'd like to repeat commands 74 through 78. In the emacs mode of bash/ksh/zsh, I would navigate back to command 74 then hit Control-O on each command to execute it and continue with the next. In vi mode I can navigate back to command 74 readily enough, but how do I then execute it and see command 75?

share|improve this question

Press <esc>, then 'k' until you get to the one you want, or something like '7k' if you know how many back, then enter to execute.

share|improve this answer
I will learn to count how many times I type 'k' getting back to (in my example) command 74, then type '16k' to get to command 75 and again for command 76 &c. Thanks. – James Mar 8 '10 at 23:25

Try this:

set -o emacs

You may be in vi mode. You can add the line above to your ~/.profile file.

Or you can add the following to your ~/.kshrc file:

: ${EDITOR:=emacs}
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .