Beginners Guide to Visual Editting on UNIX 'vi' is a screen oriented editor developed by Bill Joy for all UNIX systems. It is powerful, portable, peculiar, and a little bit hostile. This is a brief "get-you-started" summary of key features. Keep it with you when you are using UNIX. BEFORE YOU START - Make sure the CAPS LOCK button is UP on your terminal/PC! Make sure you have found the ESC key! The simplest version (if available) is started up by the command 'vedit filename' (novice mode). The other versions are: 'view files' Read only 'vi files' Power users version 'ex files' Line oriented version Important Keystrokes. ESC Escape key - exit into command mode :q! Quit edit with no changes ZZ Exit edit and save changes 'Vi' has several 'modes': Command vi interprets keystrokes as commands Input vi inputs keystrokes as data into file Pattern vi reads in a string you want to find Line vi inputs a line oriented or global command. Commands a single characters. There are more than 50 of them. Commands like i(input), o(open line), a(add) enter Input mode. ESC exits input mode and enters Command mode.... start \ Pattern (for searching) \ ?/| ^ \ | | \ V |?/ iRc... Command -iRc...------>Input Mode ZZ/:| ^ \ / done<----- | | ------<------ESC | | V | Enter/Return/ESC quit<------ Line Mode(='ex') NOTE WELL - If vi starts to write your input on the screen then you must tap ESC before it will accept commands. Essential commands Cursor movements Up k Left h Right l Down j A note on arrow keys To may make arrow keys work more reliably over a network... Put the two statements below in your .profile or execute them when you login over a network ESCDELAY=1500; export ESCDELAY If this fails try ESCDELAY=2000 or more Insert Text Place cursor after place for insertion. Tap 'i' LOWERCASE! type new text Tap ESC key <----------------------------DON'T forget the ESC key Deletions x delete character dw delete word dd delete line J Join next line to this one Undo u undo last insert/delete p put last deletion back (at currant cursor) Faster moves w forward a word b back a word % matching parenthesis, bracket, or brace G End of file nG Got to line n -- n is any line number Search /target =Return or Enter... Replace text Place cursor at start of text to be overwritten Tap 'R' UPPERCASE! type new text Tap ESC Key <----------------------------DON'T forget the ESC key Repeated commands - any command can be repeated by putting a number in front of it (except G). There are more than 100 commands used by 'vi' plus all the commands used in 'ex' plus any that the you define as well. Further ANY UNIX command can be obeyed by typing ':!command...'. Spend some time looking at the manual or reading a book on UNIX. man vi from the shell prompt or :!man vi inside the command mode of 'vi' Also See: http://csci.csusb.edu/dick/samples/vi.notes.html http://csci.csusb.edu/dick/doc/vi.commands http://csci.csusb.edu/dick/doc/vi.FAQ http://csci.csusb.edu/dick/doc/vi.archives