The document provides a quick reference card for commands and functions in the vi text editor for the Solaris operating system. It lists vi commands for moving the cursor, inserting and deleting text, searching, and making corrections. It also describes the different modes in vi and provides conventions for keyboard shortcuts.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
176 views
VI Editor For Solaris: Thoughtful Solutions
The document provides a quick reference card for commands and functions in the vi text editor for the Solaris operating system. It lists vi commands for moving the cursor, inserting and deleting text, searching, and making corrections. It also describes the different modes in vi and provides conventions for keyboard shortcuts.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
Moving around within the file , repeat last f F t T in reverse direction
Thoughtful Solutions move cursor: n| move to column n in current line
Creatively Implemented and Communicated h or to left + move to next line, at first non-white http://www.thoughtful-solutions.info/ <Ctrl-H> to left - move to previous line, at first non-white <backspace> to left vi editor for Solaris j or to next line Inserting text <CR> to next line a append text after cursor Quick Reference Card A append text at end of line k or to previous line l or to right i insert text before cursor Conventions <space bar> to right I insert text at beginning of line <CR> RETURN key 0 to beginning of line o open line below, ready for text <ESC> ESCAPE key $ to end of line O open line above, ready for text <DEL> DELETE key <Ctrl-X> press <Control> key and type x ^ to first non-white on line w right one word Changing Text italics items to be replaced by your own W right one word past punctuation cw change word (or part of word) requirements b back one word cc change line B back one word past punctuation C change part of line to right of cursor Entering/leaving vi e to end of word s substitute string for character under cursor ($ represents Solaris system prompt) E to end of word past punctuation S substitute entire line $ vi name open or create file name H to top of screen rx replace character under cursor with x $ vi +n name open file at line n L to bottom of screen r<CR> break line at cursor position $ vi + name open file at end R overwrite text to right of cursor M to middle of screen $ vi -r list saved files J join line below to current line <Ctrl-F> page forward screenfull $ vi -r name recover file name xp transpose characters <Ctrl-B> page backward screenfull $ vi name1 name2 edit first file; edit the rest via :n <Ctrl-D> scroll down half screenfull ~ change case of letter $ vi -t tag name open file name at tag <Ctrl-U> scroll up half screenfull u undo last change $ vi +/pat name open at first occurrence of pat nG go to line n U undo all changes to line $ view name open file for read only G go to last line :u undo previous last-line command :w write changes to file /pat go to next line matching pat . repeat last change :w name write to file name ?pat go to previous line matching pat :w! name overwrite file name Corrections when adding text n repeat last / or ? :wq write changes and quit <Ctrl-H> erase last input character N repeat last / or ? in reverse direction :q quit <DEL> erase last input character /pat/ +n n’th line after pat :q! quit without saving changes <back space> erase last input character ?pat? -n n’th line before pat ZZ exit from vi, saving changes <Ctrl-U> erase all input to start of line % find matching (){ or } <Ctrl-Z> stop vi for later resumption \ escape <Ctrl-U> and <DEL> ) move cursor to next sentence <Ctrl-W> erase last input word } move cursor to next paragraph vi modes <Ctrl-V> quote non-printing character ( move cursor to last sentence Command normal and initial mode <Ctrl-D> backs up one shiftwidth (autoindent) { move cursor to last paragraph (other modes return here when ^<Ctrl-D> kill autoindent on current line ]] move cursor to next section/function terminated) 0<Ctrl-D> kill all autoindentation [[ move cursor to last section/function <ESC> cancels partial command <ESC> end insertion of text fx move to x forward in current line Insert entered by a i A I o O c C s S R Fx move to x backward in current line terminate with <ESC> tx move forward to character before x Last line reading input for : / ? or ! Tx move back to character after x terminate with <ESC> or <CR> to execute ; repeat last f F t T in same direction Deleting text Pattern-matching characters Initializing options x delete character under cursor ^ beginning of line EXINIT environment variable for setting options 5x . . . and 4 characters to the right $ end of line .exrc startup file for vi; put options here X delete character before cursor . any character set x enable option 6X . . . and 5 characters to the left \< beginning of word set nox disable option dw delete word (or part of word) \> end of word set x=val set x to val 3dw . . . and 2 complete words to the right [str] any character in str set show changed options dd delete line [^str] any character not in str set all show all options 4dd . . . and the 3 following lines [x-y] any character between x and y set x? show value of option x D delete part of line to right of cursor * any number of preceding pattern :5,10 d delete lines 5–10, inclusive Useful configuration options dG delete from current line to end of file File manipulation full short meaning :sh run shell, then exit to return to vi autoindent ai supply indentation Copying and moving text :!cmd run cmd, then <CR> to return to vi autowrite aw writes before some commands yy yank or copy line :n edit next file in argument list ignorecase ic in regular expression matching 3yy . . . and the 2 following lines :n args specify new argument list list shows tabs as ^I, dd delete line :e name edit file name end-of-line as $ p put line below current line magic enables metacharacters for :e! re-edit, discarding changes P put line above current line matching :e + name edit name, starting at end yw yank or copy word (or part of word) number nu number lines :e +n name edit name, starting at line n 3yw . . . and 2 complete words to the right redraw simulate smart terminal dw delete word (or part of word) :e # edit alternate file :f or <Ctrl-G> show current file and line scroll sets number of lines for scrolling 4dw . . . and 3 complete words to the right shiftwidth sw sets number of spaces for p put word after cursor :r name insert file after cursor <Ctrl-T> P put word before cursor :n r name insert file after line n showmatch sm shows matching bracket or brace "xy yank item to buffer x :ta tag look in tags file for entry under tag slowopen slow prevents fast updating for screen "xd delete into buffer x <Ctrl-]> word under cursor is a tag; tabstop ts sets tab intervals "xp put from buffer x, after cursor window specifies number of lines in "xP put from buffer x, before cursor Adjusting the screen window <Ctrl-L> clear and redraw screen wrapscan ws search wraps round end of file "dp retrieve d’th last line <Ctrl-R> re-type, eliminating @ lines wrapmargin wm automatic line splitting :1,2 co 3 copy lines 1–2 and put after line 3 (dumb terminals only) :4,5 m 6 move lines 4–5 and put after line 6 z<CR> redraw screen with current line at top Specifying terminal type z- redraw screen with current line at bottom (% and $ are system prompts) Searching and replacing z. redraw screen with current line at centre % setenv TERM type csh and all Version 6 /pat go to next line matching pat /pat/z- redraw screen with pat line at bottom ?pat go to previous line matching pat $ TERM=type; export TERM sh in Version 7 zn. use n line window n repeat last / or ? See also man tset <Ctrl-E> scroll window down one line N repeat last / or ? in reverse direction <Ctrl-Y> scroll window up one line Some terminal types :3,7s/ab/cd/ search lines 3–7 and replace ab by cd :.,$ search from current line to end of file 2621 43 adm31 dw1 h19 vt100 Marking and returning :% search the whole file 2645 733 adm3a dw2 i100 sun `` return to previous place after / ? G ´´ return after / ? G at first non-white 300s 745 c100 gt40 mime sun-cmd mx mark position with letter x 33 act4 dm1520 gt42 owl `x move cursor to mark x This work is licensed under the Creative Commons Attribution- 37 act5 dm2500 h1500 t1061 ´x move cursor to mark x at first non-white ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.0/ 4014 adm3 dm3025 h1510 vt52