Vim Practical Reference
Vim Practical Reference
Modes in Vim
Vim, unlike many other text editors, operates in various modes for efficient text editing and a wide range of functionality. Understanding these modes is key to mastering Vim.
Normal Mode
- Description: The default mode when you open Vim. It's used for navigating within a file and executing commands.
- How to Enter: Press
Esc
in any other mode. - Key Activities: Moving around, deleting text, copying/pasting, and more.
Some useful actions in normal mode:
Key | Description |
---|---|
Arrow Keys or h , j , k , l |
File Navigation |
dd |
Delete the current cursor line |
yy |
Copy (yank) the current cursor line |
p |
Paste after the cursor |
Insert Mode
- Description: Used for inserting text.
- How to Enter: Press
i
(insert before cursor),I
(insert at the beginning of the line),a
(append, move the cursor after the current character), orA
(append, move the cursor at the end of the line) in Normal mode. - Key Activities: Typing and editing text.
Visual Mode
- Description: Used for selecting blocks of text.
- How to Enter: Press
v
(character-wise visual mode),V
(line-wise visual mode), orCtrl + v
(block-wise visual mode) in Normal mode. - Key Activities: Select text to copy, cut, or format.
Command-Line Mode
- Description: Used for entering editor commands.
- How to Enter: Press
:
in Normal mode. - Key Activities: Saving files, searching, replacing, setting preferences.
Some useful commands:
Command | Description |
---|---|
:w |
Save the current file |
:q |
Quit Vim |