The Tutorial
1
Basic Editing
2
Editing a Little Faster 
3
Searching
4
Text Blocks and Multiple Files
5
Windows
6
Basic Visual Mode
7
Commands for Programmers
8
Basic Abbreviations, Keyboard Mapping, and Initialization Files
9
Basic Command-Mode Commands
10
Basic GUI Usage
11
Dealing with Text Files
12
Automatic Completion
13
Autocommands
14
File Recovery and Command-Line Arguments
15
Miscellaneous Commands
16
Cookbook 
17
Topics Not Covered
 
Basic Editing
T
HE
 IM
EDITOR IS ONE OF THE MOST
 powerful text editors around. It is alsoextremely efficient, enabling the user to edit files with a minimum of keystrokes.This power and functionality comes at a cost, however:When getting started, users face asteep learning curve.This chapter teaches you the basic set of 10
Vim
commands you need to get startedediting. In this chapter, you learn the following:
n
The four basic movement commands
n
How to insert and delete text
n
How to get help (very important)
n
Exiting the editor After you get these commands down pat, you can learn the more advanced editingcommands.
Before You Start
If you have not installed
Vim
, you need to read Appendix A, “Installing
Vim
,” andinstall the editor.
 
4
Chapter 1 Basic Editing
If you are running on UNIX, execute the following command:
$ touch ~/.vimrc
By creating a
~/.vimrc
, you tell
Vim
that you want to use it in
Vim
mode. If this fi
le is
not present,
Vim
runs in
Vi
-compatibility mode and you lose access to many of theadvanced
Vim
features. However, you can enable the advanced features from within
Vim
at any time with this command:
:set nocompatible<Enter>
.If you are running on Microsoft Windows, the installation process creates theMicrosoft Windows version of this file,
 _vimrc
, for you.
Running
Vim
for the First Time
To start
Vim
, enter this command:
$ gvim file.txt
 Note that the
$
is the default UNIX command prompt.Your prompt might differ.If you are running Microsoft Windows, open an MS-DOS prompt window andenter this command:
C:> gvim file.txt
(Again, your prompt may differ.)In either case,
Vim
starts editing a file called
file.txt
. Because this is a new fi
le, you
get a blank window. Figure 1.1 shows what your screen will look like.The tilde (~) lines indicate lines not in the file. In other words, when
Vim
runs outof file to display, it displays tilde lines. At the bottom of a screen, a message line indi-cates the file is named
file.txt
and shows that you are creating a new file.The mes-sage information is temporary and other information overwrites it when you type thefirst character.
~~~~~~~~“file.txt”[New File]
Figure 1.1
Initial
Vim
window.
of 572