Some vim commands

Remember that vim is either in COMMAND mode or in INSERT mode. Assuming you executed ~glancast/setuplogin already, syntax highlighting should be turned on and - INSERT - will appear at the bototm of the window when you are in that mode; otherwise, in COMMAND mode, nothing appears there.

Also you should see a + in the status bar if you have made changes to the file that have not yet been saved.

Commands

These commands are all entered when in COMMAND mode by type a colon and then the name of the command:

  1. :help

    Opens a new window with help info.

  2. :q

    Close (quit) the file (in the current window, if more than one).

  3. :w

    Save (write) any changes made to the file in the current window.

  4. :q!

    Close (quit) the file even if some changes have not been made. The changes will not be saved.

  5. :sf file_name

    Split the current window and start edit file_name in the new window.

  6. :make target

    Compile by executing make utility to build the target.

  7. :cl

    List compiler errors - line numbers and message, after using the :make command.

  8. :cc

    Move the cursor to the current error.

  9. :cn

    Move the cursor to the next error.

  10. :cp

    Move the cursor to the previous error.

  11. :cope

    Show all the errors in a new window.

Other Useful Commands

These commands are not preceded by a colon. The first assumes vim is in INSERT mode. The rest assume COMMAND mode:

  1. i

    Change to INSERT mode at the current cursor postion.

  2. Esc

    Get out of INSERT mode.

  3. ZZ

    Save changes and exit vim. Like :w followed by :q

  4. x

    Delete the character under the cursor.

  5. dd

    Delete the current line.

  6. n G

    "Go" to line n

    So 1G means go to the beginning of the file.

    G with no line number means go to the end of the file.

More windows management.

  1. ctrl-w ctrl-w

    Switch cursor to the next window (cycles to first window after last window is reached).

  2. :q

    Close the current window.

  3. :on

    Make the current window the only one; close all others.