Introduction to Vim
Benefits of Vim
Fast:
keep fingers on keys: mouse not needed
powerful commands use minimal keystrokes
Examples:
Swap characters and lines: xp, ddp
Movement - mark, move, return: 0, $, ma, 1G, gg, 'a
(cit changes inside this tag)
( da) deletes these parens and their contents)
Powerful editing features (eg column operations)
Example: Column operations
Highly configurable:
Example: search for smartcase and Smartcase. Again: smartcase Smartcase
Extensible: scripting language built in, can also use perl, ruby, python
See scrollbar in statusline
Ubiquitous:
Available on many, many systems
Use same environment for programming in any language
Fun!
Brief History
vi: visual editor - Bill Joy - 1976 - BSD Unix
Vim ex mode gives an idea of life before visual editors:
Q p # 1,5p -3,+3p 1 s/DOC/doc/ u vi
Q: Enter ex mode
Display current line: p or #
Display absolute range of lines: 1,5p
Display relative range of lines: -3,+3p
Move to a new line: -3 [relative], 3 [absolute]
Substitute old to new: s/DOC/doc/
Undo: u
vi: Exit ex mode and return to normal mode
Vi was a HUGE improvement!
Vi-IMitation - Bram Moolenaar - 1991
Vi-IMproved - Bram Moolenaar - 1992
Some
Baby Pictures
Vim 5 - 1998
Syntax highlighting
Scripting language
Vim 6 - 2001
Folding
Vertical splits
Diff mode
File Browser
Command Window
Vim 7 - 2006
Spell checking
Dictionary in scripts (ie objects lite)
Omni completion (ie intellisense)
Tabbed editing
Current: Vim 7.4 (Aug 2013)
Important for Newcomers
vim uses
modes
To shift for regular mode to insert mode, press i (or other commands)
To shift from insert mode to regular mode, press escape
To exit without saving changes: esc :q! enter
To exit and save changes: esc :wq enter
How to learn
vimtutor
Run from command line or icon
Walks you through basics of vim, editing the vim tutor file
Pick a few commands, learn more as needed
Gets easier!!