How long is vimtutor
How Long is Vimtutor?§
Vim is a very powerful editor that has many commands, too many to explain in a tutor such as this. This tutor is designed to describe enough of the commands that you will be able to easily use Vim as an all-purpose editor.
The approximate time required to complete the tutor is 25-30 minutes, depending upon how much time is spent with experimentation.
The commands in the lessons will modify the text. Make a copy of this file to practice on (if you started "vimtutor" this is already a copy).
It is important to remember that this tutor is set up to teach byuse. That means that you need to execute the commands to learn themproperly. If you only read the text, you will forget the commands!
LESSON 1 SUMMARY
-
The cursor is moved using either the arrow keys or the hjkl keys.
h(left)j(down)k(up)l(right) -
To enter Vim (from the % prompt) type:
vim FILENAME<ENTER> -
To exit Vim type:
<ESC>:q!<ENTER>to trash all changes. OR type:<ESC>:wq<ENTER>to save the changes. -
To delete a character under the cursor in Normal mode type:
x -
To insert text at the cursor while in Normal mode type:
itype in text<ESC>
NOTE: Pressing <ESC> will place you in Normal mode or will cancel
an unwanted and partially completed command.
Now continue with Lesson 2.
LESSON 2 SUMMARY
-
To delete from the cursor to the end of a word type:
dw -
To delete from the cursor to the end of a line type:
d$ -
To delete a whole line type:
dd -
The format for a command in Normal mode is:
[number]commandobject ORcommand[number]object where: number - is how many times to repeat the command command - is what to do, such as d for delete object - is what the command should act upon, such as w (word), $ (to the end of line), etc. -
To undo previous actions, type:
u(lowercase u) To undo all the changes on a line type:U(capital U) To undo the undo's type:CTRL-R
LESSON 3 SUMMARY
-
To replace text that has already been deleted, type
p. This Puts the deleted text AFTER the cursor (if a line was deleted it will go on the the line below the cursor). -
To replace the character under the cursor, type
rand then the The character will replace the original. -
The change command allows you to change the specified object from the cursor to the end of the object. eg. Type
cwto change from the cursor to the end of the word,c$to change to the end of a line. -
The format for change is:
[number]cobject ORc[number]object
Now go on to the next lesson.
LESSON 4 SUMMARY
-
Ctrl-gdisplays your location in the file and the file status.Shift-Gmoves to the end of the file. A line number followed byShift-Gmoves to that line number. -
Typing
/followed by a phrase searches FORWARD for the phrase. Typing?followed by a phrase searches BACKWARD for the phrase. After a search typento find the next occurrence in the same direction orShift-Nto search in the opposite direction. -
Typing
%while the cursor is on a (,),[,],{, or } locates its matching pair.
- To substitute new for the first old on a line type :
s/old/new - To substitute new for all 'old's on a line type :
s/old/new/g - To substitute phrases between two line #'s type :
#,#s/old/new/g - To substitute all occurrences in the file type :
%s/old/new/g - To ask for confirmation each time add 'c' :
%s/old/new/gc
LESSON 5 SUMMARY
-
:!command executes an external command.Some useful examples are (MS-DOS): :
!dir- shows a directory listing. :!del FILENAME- removes file FILENAME. -
:
w FILENAMEwrites the current Vim file to disk with the name FILENAME. -
:
#,#w FILENAMEsaves the lines # through # in file FILENAME. -
:
r FILENAMEretrieves disk file FILENAME and inserts it into the current file following the cursor position.
LESSON 6 SUMMARY
-
Typing
oopens a line BELOW the cursor and places the cursor on the open line in Insert mode. Typing a capitalOopens the line ABOVE the line the cursor is on. -
Type an
ato insert text AFTER the character the cursor is on. Typing a capitalAautomatically appends text to the end of the line. -
Typing a capital
Renters Replace mode until<ESC>is pressed to exit. -
Typing "
:set xxx" sets the option "xxx"
LESSON 7: ON-LINE HELP COMMANDS
Use the on-line help system
Vim has a comprehensive on-line help system. To get started, try one of
these three:
- press the <HELP> key (if you have one)
- press the <F1> key (if you have one)
- type :help <ENTER>
Type :q <ENTER> to close the help window.
You can find help on just about any subject, by giving an argument to the
":help" command. Try these (don't forget pressing <ENTER>):
:help w
:help c_<T
:help insert-index
:help user-manual