+ Reply to Thread
Results 1 to 1 of 1




  

Thread: How to use vi key bindings in bash

      
  1. #1
    Jedi Master juanmorris is on a distinguished road juanmorris's Avatar
    Join Date
    March 3, 2010
    Posts
    17
    Rep Power
    3
    Feedback Score
    0

    Default How to use vi key bindings in bash

    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.
    Last edited by juanmorris; Mar 3rd, 2010 at 12:54 am.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads