viTricks every lazy C/C++ programer should know

  1. You can run any shell command without leaving vi by typing:
         :! command 
    
    This will run a.out:
            :! a.out
    
    This will compile the program z.c:
            :! cc z.c
    
  2. You can use % as a shorthand reference to the current file. This will compile the file you are editing:
            :! cc %
    
  3. You can repeat the last shell command you entered (good for repeated compiles):
            :!!
    
  4. You can compile the current file and place error messages in a file list
            :! cc % 2> err_lst
    
  5. You can move back and forth between two files easily. If you are in file a , and want to edit file b enter :e b . Now you want to go back to file a enter :e # . This is useful if you place the compilation errors on the file err_lst (see above) and want to go back and forth between your file and the error file.
vi has options which may be useful in programming