Due Tuesday, January 25 11:59 P.M.
This lab is intended to introduce you to vi, a programmer's text editor. While vi is much less intuitive to use than most other text editors, you will find that becoming proficient with vi allows you to perform common editing tasks more quickly.
cp -R ~gbutler/m171/spring_2005/lab2 ~This directory should contain two files called practice and assignment.
cd ~/lab2 vi practice
| Command | Movement |
|---|---|
| h | left one column |
| l | right one column |
| j | down one line |
| k | up one line |
| w | forward one word |
| b | back one word |
| { | move to start of paragraph |
| } | move to end of paragraph |
| ( | move to start of sentence |
| ) | move to end of sentence |
| $ | end of the current line |
| ^ | first non-blank character on the current line |
| | | start of current line |
| % | move to matching parenthesis/curly brace/square bracket |
| CTRL-F | forward one page |
| CTRL-D | forward one-half of a page |
| CTRL-B | back one page |
| CTRL-U | back one-half of a page |
| H | moves to first line currently visible on screen |
| L | moves to last line currently visible on screen |
| G | skips to end of file |
| f<letter> | finds first occurence of <letter> to the right of the cursor on this line |
| F<letter> | finds first occurence of <letter> to the left of the cursor on this line |
| /<phrase>Enter | finds first occurence of <phrase> after cursor |
| ?<phrase>Enter | finds first occurence of <phrase> before cursor |
| n | skips to next occurrence of search phrase |
| N | skips to previous occurrence of search phrase |
| Text Entry Command | Purpose |
|---|---|
| i | insert text before cursor on current line |
| I | insert text at beginning of current line |
| a | insert text after cursor on current line (i.e. append at cursor) |
| A | insert text at end of current line (i.e. append to current line) |
| o | insert text on new line below current |
| O | insert text on new line above current |
| Editing Command | Purpose | Places vi in insert mode? |
|---|---|---|
| x | deletes character | no |
| cc | overwrites entire line | yes |
| dd | deletes line | no |
| yy | copies line to buffer | no |
| p | pastes buffer contents at current cursor position | no |
| u | undo | no |
| CTRL-R | redo | no |
| . | repeat last editing command | no |
| Editing Command | Purpose | Places vi in insert mode? |
|---|---|---|
| d | delete text | no |
| c | change text | yes |
| y | yank text to buffer | no |
| ! | prompts for shell command to filter text | no |
| Command | Purpose |
|---|---|
| :q | quits vi |
| :q! | quits vi without saving current file |
| :w | saves file |
| :w <filename> | saves file as <filename> |
| :w! <filename> | overwrites file as <filename> |
| :wq | saves and quits |
| :n | edit next file specified on command line |
| :n! | edit next file specified on command line without saving current file |
| :n <filename> | edit file named <filename> |
| :n! <filename> | edit file named <filename> without saving current file |