|
|
Absolute Essentials
Here's what you really need to know to get off the ground:
- Unlike Emacs, vim is a modal editor: the keys on the
keyboard do different things depending on which mode you are in,
and a mode in vim is a persistent state of the editor: it stays
in whatever mode it's in until explicitly instructed to change.
The word "mode" here is not related to Emacs major or minor
modes. In Emacs, a "mode" is basically a strategy for presenting
data to the user, along with keymaps to let the use interact with
the data. Nearly every Emacs mode, however, works in essentially
the same way: you can type to insert data, and if you want to do
something else, you must use an auxiliary key like Ctrl, Meta,
or Esc to interact with the editor.
In vim, by contrast, a "mode" is a global state of the editor.
There are essentially just two modes: normal
mode and insert mode. Vim does have behavior resembling
Emacs's major modes; for example, a Vim plug-in can define
file-type-specific syntax highlighting and keymaps. However,
when the word "mode" is used in vim documentation, it always
refers to the global state of the editor - whether inserting
is enabled or not.
- By default, vim starts in normal mode,
in which the keys on the keyboard perform
commands, rather than inserting text. This is usually where
you need to be to do anything more complicated than simple
typing.
-
Esc will always return you to
normal mode. Pressing
ESC while you're in normal mode has no effect,
except possibly to elicit an annoyed beep from vim.
- The
i key will put you in insert mode,
wherein whatever you type gets added to the document you
are editing.
- The Insert key toggles between normal mode,
insert mode, and overwrite mode (a variant of insert mode
in which whatever
you type replaces existing text).
| ^X ^S ^X ^C |
Esc Z Z
| Saves the current file and exits vim. You need the ESC to get out of insert
mode, if you happen to be there. |
| ^X ^S |
Esc : w | Saves the current file without exiting. |
| ^X ^C |
Esc : q !
| This takes you out of vim without saving your work. |
| ^D |
x
| When not in insert mode, the "x" key deletes the character
under the cursor. In insert mode, the backspace and Del keys
work as expected under vim (but not necessarily all vi variants).
The only thing you cannot delete with "x" while
in normal mode is a newline. To delete a newline, type "J"
while in normal mode, which "J"oins the current line with
the next line. |
|
Last changed: 01-26-06 17:03:06
|