Vi For Smarties

Lesson Four


Useful Tricks

  1. G by itself goes to the last line of the file.
  2. ~ (tilde) toggles the case of the character under the cursor.
  3. When deleting blocks of text, move to the first line of the block, type ma to mark it, then move to the last line of the block and type d'a to delete the block.
  4. Use the above trick with y'a to yank blocks of text.

Useful Symbols

  1. Outside a colon command, $ stands for the end of the current line.
    Inside a colon command, $ stands for the last line in the file.
    Example: $ goes to the end of the current line.
    Example: d$ deletes from the cursor to the end of the current line.
    Example: :$ goes to the last line in the file.
    Example: :24,$ d deletes everything from line 24 through the last line in the file, inclusive.
  2. Outside a colon command, 0 (zero) stands for the beginning of the current line.
    Inside a colon command, 0 (zero) stands for line 0, or the line that is going to be created above the first line in the file.
    Example: 0 goes to the beginning of the current line.
    Example: :10,20 m 0 moves lines 10 through 20, inclusive, above the first line of the file.

Shell Operations

  1. Use :!command to execute command without leaving Vi.
    Example: :!date will execute the shell command date and display its output.
  2. Use :sh to spawn a new command shell inside Vi.
    Use exit to leave that shell when done.

Until you have mastered everything on this page, you are not ready for Quiz One.


Copyright © 2001 jerry_y_wang@yahoo.com. All rights reserved.