[CLUE-Tech] vi form of command history editor in bash?
Dave Anselmi
anselmi at americanisp.net
Tue Dec 18 21:19:32 MST 2001
Dave Price wrote:
> hi gang,
>
> I am trying to use the 'vi' version of history/command editing in bash.
> It seems really powerful, and I really like vi in general.
>
> Question: can anyone offfer a quick tips note, or point me to an
> online source for same that illustrates the (correct use of) major
> features of this configuration?
Do you need vi help? Search on Yahoo for vi and you'll get a fair number
of reference pages and other docs.
As for command history/editing, here are the things I usually use:
The command prompt is in insert mode when it appears. Use the escape key
to get to command mode. From there:
k (and probably up arrow) moves you up through the command history, most
recent command first. j or down arrow goes back down if you go too far.
This is good for pulling up your last command or two.
If you have to go back a ways, you can use /<regex> to search back through
the history for a command matching <regex>. After that, n goes to the next
match and N goes to the previous match.
Once you have a command line up that you want to edit, you can use the
usual motion and editing commands to change it. For example, if I type 'ls
/' and realize I wanted 'ls -l /' I do this:
esc k w i - l space enter. This does:
command mode, last command, jump to next word (the / character), insert
mode, insert '-l ', run the command. Obviously a waste of typing, unless
the path is longer than one character.
Clear as mud? The better you know vi, the fancier you can get with this,
though I don't do much beyond this sort of thing.
Dave
More information about the clue-tech
mailing list