Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
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.
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
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.
^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.
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.
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.
# 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.
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.
} operations move over paragraphs.
]] 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.
:q! quits editor without saving.
:e! re-edits the same file (starting over)
: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.
options are three kinds: numeric options,string options or toggle options.
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.
<< 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
!sortCR will run the sort command over the buffer or the selected list(Unix).
=% 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.
:ab cs Computer Science
new window size is reflected when / or ? is prefixed with count. (unable to verify this)
3. deletes 3 more words.
2. will delete two more words.
:x write if neccessary and then quit (same as
: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)
: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:
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
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!