UNIX Notes | UNIX Applications


VIM Tutor summary+

Summary + few additions

Index

(see also the full version of the tutorial):
			       LESSON 1 SUMMARY
MOVING THE CURSOR, ENTERING AND EXITING VIM, TEXT EDITING - DELETION & INSERTION

  1. The cursor is moved using either the arrow keys or the hjkl keys.
	 h (left)	j (down)       k (up)	    l (right)

  2. To enter Vim (from the % prompt) type:  vim FILENAME <ENTER>

  3. To exit Vim type:	   <ESC>   :q!	 <ENTER>  to trash all changes.
	     OR type:	   <ESC>   :wq	 <ENTER>  to save the changes.

  4. To delete a character under the cursor in Normal mode type:  x

  5. To insert text at the cursor while in Normal mode type:
	 i     type in text	<ESC>

NOTE: Pressing <ESC> will place you in Normal mode or will cancel
      an unwanted and partially completed command.
ADDition:
'fx' (find character x) moves cursor to the nearest character x to 
the right, 'Fx' to the nearest char. 'x' to the left. 't' and 'T' is similar.

			       LESSON 2 SUMMARY
DELETION COMMANDS, COMMANDS AND OBJECTS, UNDO
  1. To delete from the cursor to the end of a word type:    dw

  2. To delete from the cursor to the end of a line type:    d$

  3. To delete a whole line type:    dd

  4. The format for a command in Normal mode is:

       [number]   command   object     OR     command	[number]   object
     where:
       number - is how many times to repeat the command
       command - is what to do, such as  d  for delete
       object - is what the command should act upon, such as  w (word),
		$ (to the end of line), etc.

  5. To undo previous actions, type:	     u	 (lowercase u)
     To undo all the changes on a line type: U	 (capital U)
     To undo the undo's type:		     CTRL-R

			       LESSON 3 SUMMARY
PUT, REPLACE, CHANGE
   1. To replace text that has already been deleted, type   p .	This Puts the
     deleted text AFTER the cursor (if a line was deleted it will go on the
     line below the cursor).

  2. To replace the character under the cursor, type   r   and then the
     character which will replace the original.

  3. The change command allows you to change the specified object from the
     cursor to the end of the object.  eg. Type  cw  to change from the
     cursor to the end of the word, c$	to change to the end of a line.

  4. The format for change is:

	 [number]   c	object	      OR	c   [number]   object

			       LESSON 4 SUMMARY
LOCATION AND FILE STATUS, SEARCH, MATCHING PARENTHESES SEARCH, SUBSTITUTE
  1. Ctrl-g  displays your location in the file and the file status.
     Shift-G  moves to the end of the file.  A line number followed
     by  Shift-G  moves to that line number.

  2. Typing  /	followed by a phrase searches FORWARD for the phrase.
     Typing  ?	followed by a phrase searches BACKWARD for the phrase.
     After a search type  n  to find the next occurrence in the same direction
     or  Shift-N  to search in the opposite direction.

  3. Typing  %	while the cursor is on a  (,),[,],{, or }  locates its
     matching pair.

  4. To substitute new for the first old on a line type    :s/old/new
     To substitute new for all 'old's on a line type	   :s/old/new/g
     To substitute phrases between two line #'s type	   :#,#s/old/new/g
     To substitute all occurrences in the file type	   :%s/old/new/g
     To ask for confirmation each time add 'c'		   :%s/old/new/gc

			       LESSON 5 SUMMARY
EXECUTE AN EXTERNAL COMMAND, WRITING FILES, SELECTIVE WRITE, INSERT A FILE
  1.  :!command  executes an external command.

      Some useful examples are (MS-DOS):
	  :!dir			-  shows a directory listing.
	  :!del FILENAME	-  removes file FILENAME.

  2.  :w FILENAME  writes the current Vim file to disk with name FILENAME.

  3.  :#,#w FILENAME  saves the lines # through # in file FILENAME.

  4.  :r FILENAME  retrieves disk file FILENAME and inserts it into the
      current file following the cursor position.


			       LESSON 6 SUMMARY
OPEN (insert a line), APPEND, REPLACE II, SET OPTION
  1. Typing  o	opens a line BELOW the cursor and places the cursor on the open
     line in Insert mode.
     Typing a capital  O  opens the line ABOVE the line the cursor is on.

  2. Type an  a  to insert text AFTER the character the cursor is on.
     Typing a capital  A  automatically appends text to the end of the line.

  3. Typing a capital  R  enters Replace mode until  <ESC>  is pressed to exit.

  4. Typing ":set xxx" sets the option "xxx" (set ic => ignore case in /)

See http://iccf-holland.org/click5.html