Unformatted text preview:

vi Cheat SheetEditing ModesCommand mode Keystrokes used as commandsInsert mode Characters inserted into fileInvoking and TerminatingInvoking% vi filenameMake sure terminal setup is correct (% set term=vt100)% vi -Rfilenameinvoke vi in read only modeTerminating:wq exit vi, saving changes:q! quit vi, without saving changesRecovering LostEditing Sessions% vi -rfilenamerecover file after system crash% vi -r list all recoverable filesInitialization.exrc file containing ex commands to beexecuted upon startupEXINIT environment variable containing vicommands to be executed upon startup% vi filenamecommand mode insert mode%i, a — insert mode command<ESC> — escape:wq — exit (save changes):q! — quit (discard changes)Cursor MovementInserting TextMoving by charactersh (or backspace)move left one characterj move down one linek move up one linel (or space) move right one characterArrow keys may also be usedMoving by lines1G go to first linenG go tonth lineG go to last line^ go to beginning of line$ go to end of lineMoving by wordsw go forward one wordb go backward one wordScrollingCtrl-f scroll forward one screenCtrl-b scroll backward one screenCtrl-d scroll down one half screenCtrl-u scroll up one half screenInserting TextThe following commands place you in insert mode:i insert text before cursora append text after cursorI insert text at beginning of lineA append text at end of lineo start adding text in new line belowpresent lineO start adding text in new line abovepresent lineUse Escape to return to command modeReplacing Textrcharsubstitutechar for character undercursorR overwrite old text (end with Esc)w change current word to new word (endwith Esc)Setting Margins:set wrapmargin=xSets right margin tox, automatic word wrapDeleting, Copying, and Pasting TextSearches and SubstitutionDeleting Textx delete character at cursordd delete linendd deleten linesndw deleten wordsd$ delete to end of lined^ delete to beginning of linedG delete to end of filed1G delete to beginning of fileCopying Textyy yank current line into buffernyy yankn lines into bufferyw yank wordnyw yankn wordsPasting Textp put most recently deleted or yankedcharacters or words after cursor; put linesbelow current lineP put most recently deleted or yankedcharacters or words before cursor; putlines above current lineSimple Searches/stringsearch forward forstring?stringsearch backward forstringn repeat searchN repeat search in opposite directionGlobal Search:g/string/commandexecutecommand on lines containingstring:v/string/commandexecutecommand on lines not containingstringSubstitution:x,ys/oldstring/newstring/flagsSubstitutesnewstring foroldstring in line rangex,y.flags (optional):c wait for confirmation (y or n)g replace all occurrences within specifiedlines (default is to replace only firstoccurrence)Range specifiers:. current line$ last line% entire fileSearches and Substitution (cont.)Miscellaneous CommandsSpecial Characters[ccc] matches any specified character[^ccc] matches any character except thosespecified[c1-c2] matches any character in range^ matches beginning of line$ matches end of line. matches any one character* matches zero or more occurrences ofprevious character.* matches any number of charactersCase Sensitivity:set ignorecasedisable case sensitivity:set noic enable case sensitivityShell Commands:!commandexecutecommand:sh invoke subshell; use the exit commandto return to vi:r !commandinsert output ofcommand below currentlineUndoing Commandsu undo last changeU undo recent changes made to current lineRepeating Com-mands. repeat last command that made anediting changeReading in Files:rfilenameinsertfilename below current lineJoining LinesJ join next line to current lineLine NumbersCtrl-g display current line number and numberof lines in file:set number display line numbers:set nonumber remove displayed line numbersScreen RefreshCtrl-l refresh


View Full Document

GT AE 6382 - AE 6382 Cheat Sheet

Download AE 6382 Cheat Sheet
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view AE 6382 Cheat Sheet and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view AE 6382 Cheat Sheet 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?