Vim

Vim (Vi IMproved) is a powerful, modal text editor commonly found on Unix-like systems. Unlike most text editors, Vim operates in different modes, each optimized for a specific type of interaction—editing, navigating, or executing commands.

The Three Primary Modes

Vim operates in three core modes:

1. Normal Mode (Command Mode)

This is the default mode when opening a file. In this mode, text is not directly inserted. Instead, keystrokes are interpreted as commands for navigating, copying, deleting, or manipulating text.

Some commands in this mode include:

CommandDescription
yyCopy (yank) the current line
ddDelete (cut) the current line
3ddDelete 3 lines starting from the current
pPaste after the current line or cursor
xDelete the character under the cursor
uUndo the last change
Ctrl + rRedo the last undone change
/patternSearch downward for a pattern
?patternSearch upward for a pattern
nNext - Repeat the last search (same direction)
NPrevious - Repeat in the opposite direction

2. Insert Mode

In Insert mode, typed characters are inserted into the buffer as text.

All of the following commands can be used to switch from normal mode to insert mode:

CommandDescription
iInsert before the cursor
IInsert at the beginning of line
aAppend after the cursor
AAppend at the end of the line
oOpen a new line below the current
OOpen a new line above the current

To return to Normal Mode, press Esc.

3. Last Line Mode (Command-Line Mode)

Accessed by typing : from Normal Mode, this mode allows file-level operations and configuration commands.

Some commands include

CommandDescription
:wSave (write) the file
:qQuit
:wqSave and quit
:q!Quit without saving

To return to Normal Mode, press Esc.