next up previous contents
Next: ``vi" visual Editor - Up: ``vi" Visual Editor - Previous: Invoking vi   Contents

vi, command and input modes

One of the most important aspects to remember about vi is that most of the commands fall into one of three modes:
  1. vi mode: in this mode, most keys on the keyboard are defined to be a specific command. As the key or key sequence is issued, that command is executed.

    This is the mode vi starts in.

    At any time, pressing the $<$ESC$>$ key returns the user to vi mode.

  2. command mode: to reach that mode, one must first be in vi mode, then issue a colon (``:"). That same colon will appear at the bottom left corner of the screen. Then the command may be issued following the colon.

    One exception to this rule is the search command; a forward slash is issued instead of the colon.

  3. input mode: this is where most users expect an editor to start. This ``mode" actually refers to commands issued from vi mode but that allow the user to start inputing data into the file.

The vi commands introduced will be grouped in the three major mode types. Table 7.1 displays the most basic commands.


Table 7.1: Summary of vi Commands.
vi mode input mode command mode
  $<$ESC$>$ to end input  
$\leftarrow$ $\downarrow$ $\uparrow$ $\rightarrow$ - cursor i - insert :q - quit
h j k l - cursor a - append :q! - quit no save
CTL-f - forward screen A - append at EOL :w - write
CTL-b - backward screen O - open line :wq - write and quit
G - end of file r - replace character :num goto line num
x - delete character R - overwrite /str - find str
dw - delete word   :set all - vi settings
dd - delete line   :r file - import file
yy - copy line in buffer    
D - delete to EOL    
p - paste/put buffer    
u - undo last command    
CTL-r - redo last undo (linux/vim)    
. - repeat last editing command    
n - find next occurrence of string    
cw - change word    
# command - repeate command # times    



next up previous contents
Next: ``vi" visual Editor - Up: ``vi" Visual Editor - Previous: Invoking vi   Contents
Claude Cantin 2010-10-24