1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 1. The cursor is moved using either the arrow keys or the hjkl keys.
6 h (left) j (down) k (up) l (right)
8 2. To start Vim from the shell prompt type: vim FILENAME <ENTER>
10 3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
11 OR type: <ESC> :wq <ENTER> to save the changes.
13 4. To delete the character at the cursor type: x
15 5. To insert or append text type:
16 i type inserted text <ESC> insert before the cursor
17 A type appended text <ESC> append after the line
19 NOTE: Pressing <ESC> will place you in Normal mode or will cancel
20 an unwanted and partially completed command.
22 Now continue with lesson 2.
24 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 1. To delete from the cursor up to the next word type: dw
30 2. To delete from the cursor to the end of a line type: d$
31 3. To delete a whole line type: dd
33 4. To repeat a motion prepend it with a number: 2w
34 5. The format for a change command is:
35 operator [number] motion
37 operator - is what to do, such as d for delete
38 [number] - is an optional count to repeat the motion
39 motion - moves over the text to operate on, such as w (word),
40 $ (to the end of line), etc.
42 6. To move to the start of the line use a zero: 0
44 7. To undo previous actions, type: u (lowercase u)
45 To undo all the changes on a line, type: U (capital U)
46 To undo the undo's, type: CTRL-R
48 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53 1. To put back text that has just been deleted, type p . This puts the
54 deleted text AFTER the cursor (if a line was deleted it will go on the
55 line below the cursor).
57 2. To replace the character under the cursor, type r and then the
58 character you want to have there.
60 3. The change operator allows you to change from the cursor to where the
61 motion takes you. eg. Type ce to change from the cursor to the end of
62 the word, c$ to change to the end of a line.
64 4. The format for change is:
68 Now go on to the next lesson.
72 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77 1. CTRL-G displays your location in the file and the file status.
78 G moves to the end of the file.
79 number G moves to that line number.
80 gg moves to the first line.
82 2. Typing / followed by a phrase searches FORWARD for the phrase.
83 Typing ? followed by a phrase searches BACKWARD for the phrase.
84 After a search type n to find the next occurrence in the same direction
85 or N to search in the opposite direction.
86 CTRL-O takes you back to older positions, CTRL-I to newer positions.
88 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match.
90 4. To substitute new for the first old in a line type :s/old/new
91 To substitute new for all 'old's on a line type :s/old/new/g
92 To substitute phrases between two line #'s type :#,#s/old/new/g
93 To substitute all occurrences in the file type :%s/old/new/g
94 To ask for confirmation each time add 'c' :%s/old/new/gc
96 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101 1. :!command executes an external command.
103 Some useful examples are:
105 :!dir :!ls - shows a directory listing.
106 :!del FILENAME :!rm FILENAME - removes file FILENAME.
108 2. :w FILENAME writes the current Vim file to disk with name FILENAME.
110 3. v motion :w FILENAME saves the Visually selected lines in file
113 4. :r FILENAME retrieves disk file FILENAME and puts it below the
116 5. :r !dir reads the output of the dir command and puts it below the
120 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124 1. Type o to open a line BELOW the cursor and start Insert mode.
125 Type O to open a line ABOVE the cursor.
127 2. Type a to insert text AFTER the cursor.
128 Type A to insert text after the end of the line.
130 3. The e command moves to the end of a word.
132 4. The y operator yanks (copies) text, p puts (pastes) it.
134 5. Typing a capital R enters Replace mode until <ESC> is pressed.
136 6. Typing ":set xxx" sets the option "xxx". Some options are:
137 'ic' 'ignorecase' ignore upper/lower case when searching
138 'is' 'incsearch' show partial matches for a search phrase
139 'hls' 'hlsearch' highlight all matching phrases
140 You can either use the long or the short option name.
142 7. Prepend "no" to switch an option off: :set noic
144 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149 1. Type :help or press <F1> or <HELP> to open a help window.
151 2. Type :help cmd to find help on cmd .
153 3. Type CTRL-W CTRL-W to jump to another window.
155 4. Type :q to close the help window.
157 5. Create a vimrc startup script to keep your preferred settings.
159 6. When typing a : command, press CTRL-D to see possible completions.
160 Press <TAB> to use one completion.