Wikia

Vim Tips Wiki

Changes: Introduction to display editing using vi

Edit

Back to page

(Adjust previous/next navigation)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 5: Line 5:
 
|previous=1458
 
|previous=1458
 
|next=1468
 
|next=1468
|created=January 10, 2007
+
|created=2007
 
|complexity=basic
 
|complexity=basic
 
|author=O.R.Senthil Kumaran
 
|author=O.R.Senthil Kumaran
Line 19: Line 19:
 
These notes can serve as quick reference material to the tutorial and getting started with vi also.
 
These notes can serve as quick reference material to the tutorial and getting started with vi also.
   
<tt>d</tt> for delete
+
<code>d</code> for delete
   
<tt>c</tt> for change
+
<code>c</code> for change
   
 
both can be applied to a word by suffixing it with w.
 
both can be applied to a word by suffixing it with w.
Line 46: Line 46:
 
When the cursor is at the first position in the last line, then it is performing a computation.
 
When the cursor is at the first position in the last line, then it is performing a computation.
   
<tt>ZZ</tt> Save and quit.
+
<code>ZZ</code> Save and quit.
   
<tt>:q!</tt> end the editor session.
+
<code>:q!</code> end the editor session.
   
 
===Section 2===
 
===Section 2===
   
<tt>^D</tt> Scrolls Down in a file. D stands for Down.
+
<code>^D</code> Scrolls Down in a file. D stands for Down.
   
<tt>^U</tt> Scrolls UP. U stands for Up.
+
<code>^U</code> Scrolls UP. U stands for Up.
   
<tt>^E</tt> Expose one more line at the bottom of the screen. E stands for Expose.
+
<code>^E</code> Expose one more line at the bottom of the screen. E stands for Expose.
   
<tt>^Y</tt> Exposes one line at the top of the screen. It is non-mnemonic, but Y is next to U.
+
<code>^Y</code> Exposes one line at the top of the screen. It is non-mnemonic, but Y is next to U.
   
<tt>^F</tt> Forward in a file. Keeps few lines for read continuity.
+
<code>^F</code> Forward in a file. Keeps few lines for read continuity.
   
<tt>^B</tt> Backward in a file. Keeps few lines for read continuity.
+
<code>^B</code> Backward in a file. Keeps few lines for read continuity.
   
<tt>/</tt> Search for a pattern. n will move the next occurrence of the word.
+
<code>/</code> Search for a pattern. n will move the next occurrence of the word.
   
<tt>?</tt> Search for a pattern backward direction. n will take it to the next occurrence of the word in the reverse direction. If the search string you give is not present in the file, then a diagnostic is printed in the last line and cursor is returned to where it was before.
+
<code>?</code> Search for a pattern backward direction. n will take it to the next occurrence of the word in the reverse direction. If the search string you give is not present in the file, then a diagnostic is printed in the last line and cursor is returned to where it was before.
   
<tt>/^search</tt> will search for search in the beginning of the line.
+
<code>/^search</code> will search for search in the beginning of the line.
   
<tt>/end$</tt> will search for end at the end of the line.
+
<code>/end$</code> will search for end at the end of the line.
   
<tt>G</tt> Goes to the End of the file.
+
<code>G</code> Goes to the End of the file.
   
<tt>nG</tt> will Go to the nth line.
+
<code>nG</code> will Go to the nth line.
   
<tt>^G</tt> state of the file
+
<code>^G</code> state of the file
   
<tt>``</tt> Go to the previous position in the file,mostly used when you G'ed to a different line.
+
<code>``</code> Go to the previous position in the file,mostly used when you G'ed to a different line.
   
<tt>+</tt> moves to the next line
+
<code>+</code> moves to the next line
   
<tt>-</tt> moves to the previous line. (For + you might need to press Shift whereas for - you dont) RETURN Key has the same effect as + key.
+
<code>-</code> moves to the previous line. (For + you might need to press Shift whereas for - you dont) RETURN Key has the same effect as + key.
   
<tt>H</tt> Home
+
<code>H</code> Home
   
<tt>nH</tt> n lines from H
+
<code>nH</code> n lines from H
   
<tt>M</tt> middle of the screen.
+
<code>M</code> middle of the screen.
   
<tt>L</tt> Last line of the screen.
+
<code>L</code> Last line of the screen.
   
<tt>w</tt> advance cursor to the next word of the line.
+
<code>w</code> advance cursor to the next word of the line.
   
<tt>b</tt> move backward a word.
+
<code>b</code> move backward a word.
   
<tt>W</tt> advance cursor forward without stopping at punctuation. W think as Big Word.
+
<code>W</code> advance cursor forward without stopping at punctuation. W think as Big Word.
   
<tt>B</tt> advance cursor backward without stoppingg at punctuaton.
+
<code>B</code> advance cursor backward without stoppingg at punctuaton.
   
 
The word keys wrap around the end of the line rathar than stopping at the end.
 
The word keys wrap around the end of the line rathar than stopping at the end.
   
<tt>SPACE</tt> Advance by one position.
+
<code>SPACE</code> Advance by one position.
   
<tt>^H</tt> Backspace the cursor
+
<code>^H</code> Backspace the cursor
   
<tt>^N</tt> Next line same column.
+
<code>^N</code> Next line same column.
   
<tt>^P</tt> Previous line same column.
+
<code>^P</code> Previous line same column.
   
<tt>view</tt> instead of vi will set readonly option to the file being edited.
+
<code>view</code> instead of vi will set readonly option to the file being edited.
   
 
===Section 3===
 
===Section 3===
<tt>i</tt> stands for insert
+
<code>i</code> stands for insert
   
<tt>e</tt> moves to end of the word.
+
<code>e</code> moves to end of the word.
   
<tt>a</tt> appends. So e and then a might be helpful to pluralize the word.
+
<code>a</code> appends. So e and then a might be helpful to pluralize the word.
   
<tt>i</tt> places the cursor to the left of the word and a places the cursor to the right of the word.
+
<code>i</code> places the cursor to the left of the word and a places the cursor to the right of the word.
   
<tt>o</tt> inserts a line below.
+
<code>o</code> inserts a line below.
   
<tt>O</tt> inserts a line above.
+
<code>O</code> inserts a line above.
   
 
Many editor related commands are invoked by the same letter key and differ upper case vs lower case.The main difference being the upper case letter act in the opposite direction than (up or backward) the lower case letter.
 
Many editor related commands are invoked by the same letter key and differ upper case vs lower case.The main difference being the upper case letter act in the opposite direction than (up or backward) the lower case letter.
   
<tt>^H</tt> or <tt>#</tt> is used to backspace can be used in the editor as well.
+
<code>^H</code> or <code>#</code> is used to backspace can be used in the editor as well.
   
 
@,^X or ^U to kill input lines for the character you typed on the input line.
 
@,^X or ^U to kill input lines for the character you typed on the input line.
Line 133: Line 133:
 
Notice that you cannot erase a character which you have not inserted. Cannot backspace over end of line.
 
Notice that you cannot erase a character which you have not inserted. Cannot backspace over end of line.
   
<tt>x</tt> deletes the character.
+
<code>x</code> deletes the character.
   
<tt>nx</tt> deletes n characters.
+
<code>nx</code> deletes n characters.
   
<tt>dw</tt> deletes the word.
+
<code>dw</code> deletes the word.
   
<tt>.</tt> hitting the . keys repeats the previous command. analogous with ellipsis '...'
+
<code>.</code> hitting the . keys repeats the previous command. analogous with ellipsis '...'
   
<tt>db</tt> deletes the word backwards.
+
<code>db</code> deletes the word backwards.
   
<tt>dSPACE</tt> deletes a single character equivalent to x
+
<code>dSPACE</code> deletes a single character equivalent to x
   
<tt>cw</tt> changes the word
+
<code>cw</code> changes the word
   
<tt>dd</tt> deletes the line.
+
<code>dd</code> deletes the line.
   
<tt>@</tt> signs you see are just placeholder.It helps prevent lengthy redraws of lines.
+
<code>@</code> signs you see are just placeholder.It helps prevent lengthy redraws of lines.
   
<tt>cc</tt> changes the whole line.
+
<code>cc</code> changes the whole line.
   
<tt>ndd,ncc</tt> deletes or changes n lines.
+
<code>ndd,ncc</code> deletes or changes n lines.
   
<tt>dnL</tt> delete upto (nlines) or including the Last line.
+
<code>dnL</code> delete upto (nlines) or including the Last line.
   
<tt>u</tt> undo command to reverse the change. u also undoes a u.
+
<code>u</code> undo command to reverse the change. u also undoes a u.
   
<tt>U</tt> restores the current line to the state before you started changing it. u does only a single character.
+
<code>U</code> restores the current line to the state before you started changing it. u does only a single character.
   
 
===Section 4===
 
===Section 4===
<tt>fx</tt> finds the next x character in the current line.
+
<code>fx</code> finds the next x character in the current line.
   
<tt>;</tt> finds the next instance of the same character
+
<code>;</code> finds the next instance of the same character
   
<tt>F</tt> finds the character backwards.; repeats it backward.
+
<code>F</code> finds the character backwards.; repeats it backward.
   
<tt>tx</tt> finds the text upto the next x. helpful where you dtx - delete upto but not x;
+
<code>tx</code> finds the text upto the next x. helpful where you dtx - delete upto but not x;
   
<tt>T</tt> reverse of t
+
<code>T</code> reverse of t
   
<tt>$</tt> moves to the end of the line.
+
<code>$</code> moves to the end of the line.
   
<tt>^V</tt> Control Characters can be brought in the file by beginning an insert and then typing a Ctrl-v before the control character.
+
<code>^V</code> Control Characters can be brought in the file by beginning an insert and then typing a Ctrl-v before the control character.
   
<tt>(</tt> previous sentence
+
<code>(</code> previous sentence
   
<tt>)</tt> Next Sentence
+
<code>)</code> Next Sentence
   
<tt>d)</tt> Deletes upto the end of the current sentence.
+
<code>d)</code> Deletes upto the end of the current sentence.
   
<tt>d(</tt> If in middle of sentences deletes to the beginning. OR if at the beginning deletes the previous sentence.
+
<code>d(</code> If in middle of sentences deletes to the beginning. OR if at the beginning deletes the previous sentence.
   
<tt>{</tt> and <tt>}</tt> operations move over paragraphs.
+
<code>{</code> and <code>}</code> operations move over paragraphs.
   
<tt>[[</tt> and <tt>]]</tt> move over sections.
+
<code>[[</code> and <code>]]</code> move over sections.
   
<tt>y</tt> yanks a copy of the object which follows into the unnamed buffer.
+
<code>y</code> yanks a copy of the object which follows into the unnamed buffer.
   
<tt>"xy;</tt> x can take [a-z] stands for the buffer name and take the text in the corresponding buffer.
+
<code>"xy;</code> x can take [a-z] stands for the buffer name and take the text in the corresponding buffer.
   
<tt>p</tt> puts the text below or after the cursor.
+
<code>p</code> puts the text below or after the cursor.
   
<tt>P</tt> puts before or above the cursor.
+
<code>P</code> puts before or above the cursor.
   
<tt>"xP</tt> puts the content in the register x.
+
<code>"xP</code> puts the content in the register x.
   
<tt>YP</tt> Makes a copy of the current line and leaves you on the copy, which is before the current line.
+
<code>YP</code> Makes a copy of the current line and leaves you on the copy, which is before the current line.
   
<tt>Y</tt> is convenient abbreviation for yy.
+
<code>Y</code> is convenient abbreviation for yy.
   
<tt>Yp</tt> will make a copy of the current line and place it after the current line.
+
<code>Yp</code> will make a copy of the current line and place it after the current line.
   
<tt>nYP</tt> Number of lines to duplicate.
+
<code>nYP</code> Number of lines to duplicate.
   
<tt>"a5dd</tt> delete 5 lines and place it in a.
+
<code>"a5dd</code> delete 5 lines and place it in a.
   
<tt>"ap</tt> at the resting place,puts the contents of the buffer a.
+
<code>"ap</code> at the resting place,puts the contents of the buffer a.
   
<tt>:e</tt> edit another file.
+
<code>:e</code> edit another file.
   
 
===Section 5===
 
===Section 5===
<tt>:q!</tt> quits editor without saving.
+
<code>:q!</code> quits editor without saving.
   
<tt>:e!</tt> re-edits the same file (starting over)
+
<code>:e!</code> re-edits the same file (starting over)
   
<tt>set autowrite</tt>
+
<code>set autowrite</code>
   
<tt>:n</tt> move the next file in when you do a :e to open a new file from the current file.
+
<code>:n</code> move the next file in when you do a :e to open a new file from the current file.
   
<tt>:!cmdCR</tt> Get to a shell and execute a single command. The system will run the single command cmd and system will ask you to hit Return to continue. You can give another command when it asks for a Return.
+
<code>:!cmdCR</code> Get to a shell and execute a single command. The system will run the single command cmd and system will ask you to hit Return to continue. You can give another command when it asks for a Return.
   
<tt>:sh</tt> Will give you a new shell. Do a Ctrl-D when done. (Unix)
+
<code>:sh</code> Will give you a new shell. Do a Ctrl-D when done. (Unix)
   
<tt>mx</tt> marks the current line with a letter.
+
<code>mx</code> marks the current line with a letter.
   
<tt>`a</tt> moves to the marked position.
+
<code>`a</code> moves to the marked position.
   
<tt>Ctrl-L</tt> Refreshes the Screen.
+
<code>Ctrl-L</code> Refreshes the Screen.
   
 
@ characters in the screen can be removed by pressing Ctrl-R (??)
 
@ characters in the screen can be removed by pressing Ctrl-R (??)
   
<tt>zRETURN</tt> will place the line to the top of the window
+
<code>zRETURN</code> will place the line to the top of the window
   
<tt>z.</tt> will place the line under the cursor to the middle of the window.
+
<code>z.</code> will place the line under the cursor to the middle of the window.
   
<tt>z-</tt> will place the line under the cursor at the end of the window.
+
<code>z-</code> will place the line under the cursor at the end of the window.
   
 
===Section 6===
 
===Section 6===
Line 250: Line 250:
 
options are three kinds: numeric options,string options or toggle options.
 
options are three kinds: numeric options,string options or toggle options.
   
<tt>:set</tt>
+
<code>:set</code>
   
<tt>:set opt?CR</tt>
+
<code>:set opt?CR</code>
   
<tt>:set allCR</tt>
+
<code>:set allCR</code>
   
<tt>vi -r</tt> for recovering files if the system crashed.
+
<code>vi -r</code> for recovering files if the system crashed.
   
<tt>:set wm1=10CR</tt> Setting the wrap margin to 10. This causes all lines to be broken at a space at least 10 columns from the right hand edge of the screen.
+
<code>:set wm1=10CR</code> Setting the wrap margin to 10. This causes all lines to be broken at a space at least 10 columns from the right hand edge of the screen.
   
<tt>J</tt> joins the line.
+
<code>J</code> joins the line.
   
 
set autoindent
 
set autoindent
Line 266: Line 266:
 
set shiftwidth
 
set shiftwidth
   
<tt><<</tt> Shift One line left
+
<code><<</code> Shift One line left
   
<tt>>></tt> Shift One line right
+
<code>>></code> Shift One line right
   
<tt><L</tt> Shift rest of the display left
+
<code><L</code> Shift rest of the display left
   
<tt>>L</tt> Shift rest of the display right
+
<code>>L</code> Shift rest of the display right
   
<tt>%</tt> Matching Parenthesis
+
<code>%</code> Matching Parenthesis
   
<tt>]]</tt> moves to the next } in a program. useful with <tt>y]]</tt>
+
<code>]]</code> moves to the next } in a program. useful with <code>y]]</code>
   
<tt>!sortCR</tt> will run the sort command over the buffer or the selected list(Unix).
+
<code>!sortCR</code> will run the sort command over the buffer or the selected list(Unix).
   
 
set lisp
 
set lisp
   
<tt>=%</tt> at the beginning of the function, will realign all the lines of the function declaration.
+
<code>=%</code> at the beginning of the function, will realign all the lines of the function declaration.
   
<tt>:map lhs rhsCR</tt>
+
<code>:map lhs rhsCR</code>
   
<tt>:map q :wq</tt>
+
<code>:map q :wq</code>
   
 
(This is supposed to be :map q :wq^V^VCRCR;the first CR for map association and second CR for the command itself)
 
(This is supposed to be :map q :wq^V^VCRCR;the first CR for map association and second CR for the command itself)
Line 293: Line 293:
   
 
===Section 7===
 
===Section 7===
<tt>:abbreviate (:ab)</tt>
+
<code>:abbreviate (:ab)</code>
   
<tt>:unabbreviate (:una)</tt>
+
<code>:unabbreviate (:una)</code>
   
<tt>:ab cs Computer Science</tt>
+
<code>:ab cs Computer Science</code>
   
 
===Section 8===
 
===Section 8===
Line 307: Line 307:
 
new window size is reflected when / or ? is prefixed with count. (unable to verify this)
 
new window size is reflected when / or ? is prefixed with count. (unable to verify this)
   
<tt>dw</tt> <tt>3.</tt> deletes 3 more words. <tt>2.</tt> will delete two more words.
+
<code>dw</code> <code>3.</code> deletes 3 more words. <code>2.</code> will delete two more words.
   
<tt>:x</tt> write if neccessary and then quit (same as <tt>ZZ</tt>)
+
<code>:x</code> write if neccessary and then quit (same as <code>ZZ</code>)
   
<tt>:e name</tt>; edit file name
+
<code>:e name</code>; edit file name
   
<tt>:e!</tt> reedit discarding the changes.
+
<code>:e!</code> reedit discarding the changes.
   
<tt>:e</tt> + n edit starting at the end.
+
<code>:e</code> + n edit starting at the end.
   
<tt>:e</tt> +n edit starting at n
+
<code>:e</code> +n edit starting at n
   
<tt>:e #</tt> edit an alternate file
+
<code>:e #</code> edit an alternate file
   
<tt>:w filename</tt>;write filename
+
<code>:w filename</code>;write filename
   
<tt>:w! filename</tt>;overwrite filename
+
<code>:w! filename</code>;overwrite filename
   
<tt>:x,yw</tt> name write lines x through y to name
+
<code>:x,yw</code> name write lines x through y to name
   
<tt>:r name</tt> read the file name to buffer
+
<code>:r name</code> read the file name to buffer
   
<tt>:n</tt> edit the next file in the arg list
+
<code>:n</code> edit the next file in the arg list
   
<tt>:n!</tt> edit next file, discarding the changes to the current.
+
<code>:n!</code> edit next file, discarding the changes to the current.
   
<tt>:n args</tt>;specify new argument list
+
<code>:n args</code>;specify new argument list
   
<tt>:ta</tt> tag edit file containing tag. (:help ta)
+
<code>:ta</code> tag edit file containing tag. (:help ta)
   
<tt>:e</tt> +/pat
+
<code>:e</code> +/pat
   
<tt>:e</tt> +?pat
+
<code>:e</code> +?pat
   
<tt>:ta</tt> can be used with ctags programs. :ta <function_name> will move you to that function.
+
<code>:ta</code> can be used with ctags programs. :ta <function_name> will move you to that function.
   
<tt>/pattern-n</tt> nth line before the line containing the pattern
+
<code>/pattern-n</code> nth line before the line containing the pattern
   
<tt>/pattern+n</tt> nth line after the line containing the pattern
+
<code>/pattern+n</code> nth line after the line containing the pattern
   
<tt>set ic</tt> ignores the case during the search
+
<code>set ic</code> ignores the case during the search
   
<tt>set noic</tt> toggles the above.
+
<code>set noic</code> toggles the above.
   
<tt>set nomagic</tt> the search is now NOT regex
+
<code>set nomagic</code> the search is now NOT regex
   
<tt>Q</tt> escapes you to ex mode
+
<code>Q</code> escapes you to ex mode
   
 
An appendix of all the characters is presented.
 
An appendix of all the characters is presented.

Latest revision as of 07:54, July 11, 2012

Tip 1465 Printable Monobook Previous Next

created 2007 · complexity basic · author O.R.Senthil Kumaran · version 5.7


Notes to accompany the Tutorial "Introduction To Display Editing using vi" by William Joy and Mark Horton.

Bill Joy's "Introduction to Display editing using vi" is a great tutorial to understand and appreciate the rationale behind the vi keystrokes. The material is relevant for the Vim editor as well.

These notes can serve as quick reference material to the tutorial and getting started with vi also.

d for delete

c for change

both can be applied to a word by suffixing it with w.

Section 1Edit

man setenv

man tset *these are for specifying the terminal type, not applicable to this era*

hjkl as cursor positioning keys.

If not sure on which state the editor is in, hitting ESC key for few times makes the editor go in quiescent state.

ESC Key,Return Key and DEL Key

/ key

Now when you have pressed / key and the cursor is at the bottom, you can return to the previous position by pressing the DEL key.

Hitting the DEL or RUB key can be called as sending an interrupt.

The editor oftens echos your commands at the last line of the terminal.

When the cursor is at the first position in the last line, then it is performing a computation.

ZZ Save and quit.

:q! end the editor session.

Section 2Edit

^D Scrolls Down in a file. D stands for Down.

^U Scrolls UP. U stands for Up.

^E Expose one more line at the bottom of the screen. E stands for Expose.

^Y Exposes one line at the top of the screen. It is non-mnemonic, but Y is next to U.

^F Forward in a file. Keeps few lines for read continuity.

^B Backward in a file. Keeps few lines for read continuity.

/ Search for a pattern. n will move the next occurrence of the word.

? Search for a pattern backward direction. n will take it to the next occurrence of the word in the reverse direction. If the search string you give is not present in the file, then a diagnostic is printed in the last line and cursor is returned to where it was before.

/^search will search for search in the beginning of the line.

/end$ will search for end at the end of the line.

G Goes to the End of the file.

nG will Go to the nth line.

^G state of the file

`` Go to the previous position in the file,mostly used when you G'ed to a different line.

+ moves to the next line

- moves to the previous line. (For + you might need to press Shift whereas for - you dont) RETURN Key has the same effect as + key.

H Home

nH n lines from H

M middle of the screen.

L Last line of the screen.

w advance cursor to the next word of the line.

b move backward a word.

W advance cursor forward without stopping at punctuation. W think as Big Word.

B advance cursor backward without stoppingg at punctuaton.

The word keys wrap around the end of the line rathar than stopping at the end.

SPACE Advance by one position.

^H Backspace the cursor

^N Next line same column.

^P Previous line same column.

view instead of vi will set readonly option to the file being edited.

Section 3Edit

i stands for insert

e moves to end of the word.

a appends. So e and then a might be helpful to pluralize the word.

i places the cursor to the left of the word and a places the cursor to the right of the word.

o inserts a line below.

O inserts a line above.

Many editor related commands are invoked by the same letter key and differ upper case vs lower case.The main difference being the upper case letter act in the opposite direction than (up or backward) the lower case letter.

^H or # is used to backspace can be used in the editor as well.

@,^X or ^U to kill input lines for the character you typed on the input line.

Notice that you cannot erase a character which you have not inserted. Cannot backspace over end of line.

x deletes the character.

nx deletes n characters.

dw deletes the word.

. hitting the . keys repeats the previous command. analogous with ellipsis '...'

db deletes the word backwards.

dSPACE deletes a single character equivalent to x

cw changes the word

dd deletes the line.

@ signs you see are just placeholder.It helps prevent lengthy redraws of lines.

cc changes the whole line.

ndd,ncc deletes or changes n lines.

dnL delete upto (nlines) or including the Last line.

u undo command to reverse the change. u also undoes a u.

U restores the current line to the state before you started changing it. u does only a single character.

Section 4Edit

fx finds the next x character in the current line.

; finds the next instance of the same character

F finds the character backwards.; repeats it backward.

tx finds the text upto the next x. helpful where you dtx - delete upto but not x;

T reverse of t

$ moves to the end of the line.

^V Control Characters can be brought in the file by beginning an insert and then typing a Ctrl-v before the control character.

( previous sentence

) Next Sentence

d) Deletes upto the end of the current sentence.

d( If in middle of sentences deletes to the beginning. OR if at the beginning deletes the previous sentence.

{ and } operations move over paragraphs.

[[ and ]] move over sections.

y yanks a copy of the object which follows into the unnamed buffer.

"xy; x can take [a-z] stands for the buffer name and take the text in the corresponding buffer.

p puts the text below or after the cursor.

P puts before or above the cursor.

"xP puts the content in the register x.

YP Makes a copy of the current line and leaves you on the copy, which is before the current line.

Y is convenient abbreviation for yy.

Yp will make a copy of the current line and place it after the current line.

nYP Number of lines to duplicate.

"a5dd delete 5 lines and place it in a.

"ap at the resting place,puts the contents of the buffer a.

:e edit another file.

Section 5Edit

:q! quits editor without saving.

:e! re-edits the same file (starting over)

set autowrite

:n move the next file in when you do a :e to open a new file from the current file.

:!cmdCR Get to a shell and execute a single command. The system will run the single command cmd and system will ask you to hit Return to continue. You can give another command when it asks for a Return.

:sh Will give you a new shell. Do a Ctrl-D when done. (Unix)

mx marks the current line with a letter.

`a moves to the marked position.

Ctrl-L Refreshes the Screen.

@ characters in the screen can be removed by pressing Ctrl-R (??)

zRETURN will place the line to the top of the window

z. will place the line under the cursor to the middle of the window.

z- will place the line under the cursor at the end of the window.

Section 6Edit

set slow

set noslow

set redraw

set noredraw

options are three kinds: numeric options,string options or toggle options.

:set

:set opt?CR

:set allCR

vi -r for recovering files if the system crashed.

:set wm1=10CR Setting the wrap margin to 10. This causes all lines to be broken at a space at least 10 columns from the right hand edge of the screen.

J joins the line.

set autoindent

set shiftwidth

<< Shift One line left

>> Shift One line right

<L Shift rest of the display left

>L Shift rest of the display right

% Matching Parenthesis

]] moves to the next } in a program. useful with y]]

!sortCR will run the sort command over the buffer or the selected list(Unix).

set lisp

=% at the beginning of the function, will realign all the lines of the function declaration.

:map lhs rhsCR

:map q :wq

(This is supposed to be :map q :wq^V^VCRCR;the first CR for map association and second CR for the command itself)

Placing a ! after the word map causes the map to be applied in the input mode rather than command mode.

Section 7Edit

:abbreviate (:ab)

:unabbreviate (:una)

:ab cs Computer Science

Section 8Edit

5a+-----ESC

+-----+-----+-----+-----+-----

new window size is reflected when / or ? is prefixed with count. (unable to verify this)

dw 3. deletes 3 more words. 2. will delete two more words.

:x write if neccessary and then quit (same as ZZ)

:e name; edit file name

:e! reedit discarding the changes.

:e + n edit starting at the end.

:e +n edit starting at n

:e # edit an alternate file

:w filename;write filename

:w! filename;overwrite filename

:x,yw name write lines x through y to name

:r name read the file name to buffer

:n edit the next file in the arg list

:n! edit next file, discarding the changes to the current.

:n args;specify new argument list

:ta tag edit file containing tag. (:help ta)

:e +/pat

:e +?pat

:ta can be used with ctags programs. :ta <function_name> will move you to that function.

/pattern-n nth line before the line containing the pattern

/pattern+n nth line after the line containing the pattern

set ic ignores the case during the search

set noic toggles the above.

set nomagic the search is now NOT regex

Q escapes you to ex mode

An appendix of all the characters is presented.

Further learning the vi, Vim editor:

:vimtutor

An Introduction to Display Editing with Vi http://docs.freebsd.org/44doc/usd/12.vi/paper.html

Seven habits of effective text editing http://www.moolenaar.net/habits.html

Vim site www.vim.org

CommentsEdit

I am tempted to put a dodgy template on this tip. There are better ways to get Vim info (and some of the above is bad information for anyone with Vim 7.0 or later). It's been quite a while since I've seen a RUB key!


Around Wikia's network

Random Wiki