Introduction to vi
Intro to vi vi is a ubiquitous text editor. It is available for Linux, Unix, Mac OS X and Windows (from and others). To run vi, simple type vi vi test.cpp
Intro to vi vi has 3 modes: 1. edit mode 2. insert mode 3. command mode
vi mode: edit Escreturn to edit mode /search-string /search again arrow keys Retnext line ^beginning of line $end of line xdelete char dwdelete word dddelete line n dddelete n lines uundo Ctrl-bbackwards a screenful of text Ctrl-fforwards a screenful of text Ctrl-rredo
vi mode: insert astart adding after cursor Astart adding at end of line iinsert in front of current cursor position Istart adding in front of line oopen a new line underneath current line Oopen a new line above current line Escexit insert mode
vi mode: command Command mode is entered with : from edit/insert mode. :qquit (if changes haven’t been made) :q!quit without saving changes :wsave changes; don’t quit :xsave changes and quit
copy-paste steps: 1. Place cursor (anywhere) on line you wish to copy. 2. shift-yyank (makes a copy of the line) or n shift-y to yank n lines 3. Move to location where you wish to paste line. 4. shift-pput
cut-paste steps: 1. Place cursor (anywhere) on line you wish to cut. 2. dddelete line or n dd to delete n lines 3. Move to location where you wish to paste line. 4. shift-pput
Remember… Escreturn to move/modify mode :xsave changes; quit :qquit :q!quit without saving changes dddelete line dwdelete word iinsert uundo