Key bindings allow you to move around and edit commands and command history as if you were editing lines in a text file with a text editor. Keys can be bound to either vi mode or Emacs mode.
To set vi keys, type:
set -o vi
vi has two modes: insert and command. The same goes for a command line with vi key bindings. Insert mode lets you type commands while command mode lets you move around and edit them. Here are some of the key bindings in vi mode. All keystrokes except <esc> are bound in command mode:
<esc> - enter command mode
i - enter insert mode (you can now type commands)
a - enter insert mode, appending after the cursor
h - move the cursor left one character
j - move forward in the command history
k - move back in the command history
l - move the cursor right one character
w - move back one word
b - move forward one word
e - move to the end of a word
^ - go to the beginning of the current command
0 - same as ^
$ - go to the end of the current command
cw - change the current word (delete word and go into insert mode)
c$ - change to the end of the command
cc - change the entire command
dw - delete the current word (stay in command mode)
d$ - delete to the end of the command
dd - delete the entire command
x - delete the character under the cursor
r - replace one character
R - overwrite characters
u - undo last action
U - restore the current command to its original state
/word - go to the first occurrence of word in the command history
One quirk of vi key bindings: If you enter insert mode using i, you will not be able to delete the last character of the command. You must go into command mode and type x.
You can enter a command in either insert mode or command mode.

LinkBack URL
About LinkBacks






Reply With Quote
Bookmarks