Quick Vim Tutorial

Vim Modes The basics

These are the very basic commands needed to start vim, open a file, edit, and save a file.
Some Useful Options for ~/.vimrc
  • :set autoindent - Automatically indent following lines to the indentation
  • :set smartindent - Context-sensitive indentation (great when coding)
  • :set ignorecase - Ignore case during pattern matching.
  • :set number - Display line numbers
  • :set shiftwidth=n - Width for shifting
  • :syntax on - Turn on Syntax Highlighting (also great when coding)

    Mixed File Format:
    Unix, Windows, and MAC all use different end of line (EOL) character. Vim typically figures out the fileformat for you automatically. A file with \r\n linefeeds becomes dos, a file with \r only becomes mac, and a file with \n only becomes unix. However, when a file contains BOTH \r\n and \n linefeeds, Vim declares it as a UNIX file and displays the ^M (\r) characters. These mixed-EOL files come about from stuff edited in different editors: some editors only save the lines actually changed, converting only part of the file to DOS-style or MAC-style line endings. This also happens with files generated by user-written programs if a consistent mechanism for line termination isn't used. Here is the trick to remove all the ^M's. References: There are many more commands for using vim. What I have shown above will give a user the basic tools for editing text files. For all the commands and tricks for programmers, you can check out
  • the VIM Tutorial (572 page PDF).
  • the Vim Source Forge website
  • The vimtutor. To execute the tutor, open a command line and type vimtutor