![]() |
Main /
ViMain.Vi HistoryHide minor edits - Show changes to markup February 05, 2008, at 01:38 PM
by -
Changed lines 5-6 from:
INSERTING TEXT to:
INSERTING TEXTChanged lines 18-19 from:
DELETING TEXT to:
DELETING TEXTChanged lines 30-41 from:
UNDOING AND REPEATING COMMANDS u Undo last command U Restore current line to original state "np Retrieve last nth delete(last 9 deletes are in a buffer)" n Repeat last / or ? search command N Repeat, in reverse direction, last / or ? search command ; (semi-colon) Repeat last f, F, t or T search command , (comma) Repeat, in reverse direction, last f, F, t or T search command . (period) Repeat last text change command to:
UNDOING AND REPEATING COMMANDS
February 05, 2008, at 01:36 PM
by -
Changed lines 125-126 from:
COPYING AND PLACING TEXT( These commands may be preceded by a number to multiply commands ) || to:
COPYING AND PLACING TEXT( These commands may be preceded by a number to multiply commands ) Changed line 132 from:
USEFUL OPTIONSto:
USEFUL OPTIONSFebruary 05, 2008, at 12:41 PM
by -
Changed lines 119-149 from:
:n,m s/<str1>/<str2>/<opt> Search from n to m for <str1> and replace it with <str2> with option <opt>.
<opt> can be c - confirm changes
g - global replace
p - to print changed lines
(Ex- :1,$ s/foo/bar/g Replaces every occurence of "foo" with the string "bar".) :g/<str>/<cmd> Run <cmd> on all lines that contain <str> :g/<str1>/s/<str2>/<str3>/ Find line containing <str1>, replace <str2> with <str3> :v/<str>/<cmd> Execute <cmd> on all lines that do not match <str> COPYING AND PLACING TEXT ( These commands may be preceded by a number to multiply commands ) yy or Y Yank current line into the buffer ( copy ) nyy or nY Yank n amount of line into buffer p Insert line(s) in buffer after cursor; also prints last deleted text P Insert line(s) in buffer before cursor USEFUL OPTIONS :set all Displays all options you may "set" :set showmode Displays "INPUT MODE" while in input mode :set tabstop=n Sets the tabwidth of the tab key to n spaces; 8 is default, but 4 may be preferable :set list Displays all control characters in document; to:
COPYING AND PLACING TEXT( These commands may be preceded by a number to multiply commands ) ||
USEFUL OPTIONS
February 05, 2008, at 12:37 PM
by -
Changed lines 20-33 from:
CTRL-h or Backspace While in Input Mode delete previous character Typing a number before these commands will delete that amount of characters, words, or lines. x Deletes current character dw Delete current word dd Deletes current line :n,md Deletes lines n through m D or d$ Delete from cursor to end of current line dcursor_cmd Delete text to cursor to cursor_cmd(e.g.,dG deletes from current line to end of file) to:
Typing a number before these commands will delete that amount of characters, words, or lines.
Changed lines 109-119 from:
SEARCHING f<char> Search forward in current line to <char> F<char> Search backwards in curretn line to <char> /<string> Find next occurence of <string> ?<string> Find previous occurence of <string> :set ic Ingnore case while searching :set noic Case sensitive while searching (default) GLOBAL SEARCH AND REPLACE to:
SEARCHING
GLOBAL SEARCH AND REPLACEJanuary 22, 2008, at 05:49 AM
by -
Changed lines 5-6 from:
INSERTING TEXT to:
INSERTING TEXT Changed lines 8-21 from:
a Append after cursor A Append after end of current line i Insert before cursor I Insert before beginning of current line o Open new line below current line and insert O Open new line above current line and insert CTRL-vchar While inserting, ignore special meaning of char (e.g., for inserting characters like Esc and control
characters)
:r file Read file, and insert after current line J Join next line to end of current line DELETING TEXT to:
DELETING TEXT January 22, 2008, at 05:43 AM
by -
Added lines 1-155:
VI commandsINSERTING TEXT To leave the Insert mode, press 'Esc' a Append after cursor A Append after end of current line i Insert before cursor I Insert before beginning of current line o Open new line below current line and insert O Open new line above current line and insert CTRL-vchar While inserting, ignore special meaning of char (e.g., for inserting characters like Esc and control
characters)
:r file Read file, and insert after current line J Join next line to end of current line DELETING TEXT CTRL-h or Backspace While in Input Mode delete previous character Typing a number before these commands will delete that amount of characters, words, or lines. x Deletes current character dw Delete current word dd Deletes current line :n,md Deletes lines n through m D or d$ Delete from cursor to end of current line dcursor_cmd Delete text to cursor to cursor_cmd(e.g.,dG deletes from current line to end of file) UNDOING AND REPEATING COMMANDS u Undo last command U Restore current line to original state "np Retrieve last nth delete(last 9 deletes are in a buffer)" n Repeat last / or ? search command N Repeat, in reverse direction, last / or ? search command ; (semi-colon) Repeat last f, F, t or T search command , (comma) Repeat, in reverse direction, last f, F, t or T search command . (period) Repeat last text change command MOVING THE CURSOR k or CTRL-p Up j or CTRL-j or CTRL-n Down h or CTRL-h or Backspace Left l (lower case L) or Spacebar Right w or W Start of next word; W ignores punctuation b or B Start of previous word; B ignores punctuation e or E End of next word; E ignores punctuation 0 (zero) or | (pipe) First column in current line n| Column n in current line ^ (caret) First non-blank character in current line $ Last character in current line + or Return First character in next line - First non-blank character in previous line 1G First line in file G Last line in file G$ Last character in file nG Line n in file ( Back to beginning of sentence ) Forward to beginning of next sentence \{ Back to beginning of paragraph \} Forward to beginning of next paragraph PATTERN MATCHING Pattern matching characters help find strings with similar char- acteristics. :set magic Allow pattern matching with special characters (default) :set nomagic Allow only ^ and $ as special characters ^ (caret) Match beginning of line $ Match end of line . (period) Match any single character \< Match beginning of word \> Match end of word [str] Match any single character in str [^str] Match any character not in str [a-n] Match any character between a and n
in expression \ Escape meaning of next character(e.g. \$ lets you search for $) \\ Escape the \ character SAVE TEXT AND EXIT VI ZZ or :wq or :x Save file and exit vi :w file Save file but do not exit. Omitting file saves current file :w! file Save file overriding normal checking :n,mw file Write lines n through m to file :n,mw>>file Append lines n through m to end of file :q Leave vi, saving changes before last write (you may be prompted to save first) :q! Leave vi without saving any changes since last write Q Escape vi into ex editor with same file; :vi returns :e! File-edit current file, disregarding changes since last write. SEARCHING f<char> Search forward in current line to <char> F<char> Search backwards in curretn line to <char> /<string> Find next occurence of <string> ?<string> Find previous occurence of <string> :set ic Ingnore case while searching :set noic Case sensitive while searching (default) GLOBAL SEARCH AND REPLACE :n,m s/<str1>/<str2>/<opt> Search from n to m for <str1> and replace it with <str2> with option <opt>.
<opt> can be c - confirm changes
g - global replace
p - to print changed lines
(Ex- :1,$ s/foo/bar/g Replaces every occurence of "foo" with the string "bar".) :g/<str>/<cmd> Run <cmd> on all lines that contain <str> :g/<str1>/s/<str2>/<str3>/ Find line containing <str1>, replace <str2> with <str3> :v/<str>/<cmd> Execute <cmd> on all lines that do not match <str> COPYING AND PLACING TEXT ( These commands may be preceded by a number to multiply commands ) yy or Y Yank current line into the buffer ( copy ) nyy or nY Yank n amount of line into buffer p Insert line(s) in buffer after cursor; also prints last deleted text P Insert line(s) in buffer before cursor USEFUL OPTIONS :set all Displays all options you may "set" :set showmode Displays "INPUT MODE" while in input mode :set tabstop=n Sets the tabwidth of the tab key to n spaces; 8 is default, but 4 may be preferable :set list Displays all control characters in document; |