How to get started with Vi or ViM ================================= To use, or not to use: A comment to the beginner ------------------------------------------------ Vi comes with practically EVERY UNIX-type operating system (e.g. all Linux distributions, BSD, Mac OSX, Sun Solaris, you name it). It does not require a GUI (Graphical User-Interface), and can be used for text file editing when working in a shell of a remote server. A variety of other non-GUI text editors exists, e.g. pico, nano, joe, emacs, which may be less versatile, but easier to handle when used infrequently. I often use Nano or Pico. Occasionally, however, Vi is the only choice, and then it's good to have at least some very basic understanding of how to use it. It's probably the most powerful non-GUI text editor, the other one I am aware of being a non-GUI version of emacs (which is often NOT installed on the computer). A GUI-version of ViM exists. Start Vi -------- In a command shell, enter vi filename End Vi ------ Enter :q! There are many other ways to exit Vi, but if you just want to get out of it, without saving etc., this is the command you want to use. Modes ----- Vi's two most common operating modes are 1) command mode (ESC) 2) insert mode (i) Upon startup, Vi is in command mode. Toggle the modes by hitting the "i" or "ESC" keys, respectively. Basic movement -------------- In command and insert modes, Arrow keys work for moving the cursor. In command mode, h, l, k, j work like the arrow keys b and w move left and right to the next word or token. g^ first character of screen line g$ last character of screen line Edit ---- In command mode, x deletes character under cursor (deletes to the right) X deletes character before cursor (deletes to the left) dd deletes current line D deletes to the end of the line In insert mode, but not on all machines I used, BACKSPACE deletes the character before the cursor position. For deletions, the command mode is often the better choice. Search ------ Initiate a search for a string of characters, e.g. "foo", by / foo File operations --------------- In command mode, of course, :w write a file to disk :wq write a file to disk, then quit Vi :q quite, but check if recent changes to file were written :q! quite without checking (unwritten changes will be lost!) Look up more commands --------------------- The VIM QUICK REFERENCE CARD, published under GNU license, two printed letter or A4 pages, gives a good summary of ViM commands. Just search for5D it on the web. There are also many useful websites.