Linux For Cynics One user's experiences with Linux


How to use vi-mode in bash

If you are a fan of vi you probably want everything under the sun to work like vim does. To use vi-style input in Terminal, all you have to do is add this line to your .bashrc file:

set -o vi

If you just want to try it out, you can just type that in Terminal, and it will be in vi mode for the rest of your session. Keep in mind that vi has two modes - insert and command. To switch between them, hit ESC.

Now, if you haven't used vi before, here're some useful commands: (Remember, hit ESC to get into command mode).

h	 Move cursor left
l	 Move cursor right
A	 Move cursor to end of line and put in insert mode
0	 (zero) Move cursor to beginning of line (doesn't put in insert mode) 
i	 Put into insert mode at current position
a	 Put into insert mode after current position
dd	 Delete line (saved for pasting)
D	 Delete text after current cursor position (saved for pasting)
p	 Paste text that was deleted
j	 Move up through history commands
k	 Move down through history commands
u	 Undo
Comments (1) Trackbacks (0)
  1. What does vi stand for? For me, it will always stand for “Village Idiot”

Leave a comment

No trackbacks yet.