Fundamentals 9 min read

Master Vim Basics: Essential Commands and Modes for Linux Users

This guide introduces Vim’s core concepts, explains each editing mode, and provides step‑by‑step commands for inserting, navigating, editing, searching, and visual selection, enabling Linux users to become proficient with this powerful text editor.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Vim Basics: Essential Commands and Modes for Linux Users

Introduction

Vim is a highly extensible, cross‑platform text editor derived from the classic Vi editor, available by default on most Linux and BSD systems. It offers efficient, keyboard‑driven workflows that let programmers focus on editing code rather than using a mouse.

Vim Modes Overview

Vim operates with several distinct modes, each providing specific functionality:

Normal mode : for navigating and issuing commands.

Insert mode : for entering text.

Visual mode : for selecting text blocks.

Command‑line mode : for executing Ex commands (prefixed with :).

Vim mode diagram
Vim mode diagram

Using Insert Mode

When Vim starts, it is in normal mode. Press i to switch to insert mode at the cursor position, or o to open a new line below, O to open a line above. Type your text, then press Esc to return to normal mode.

Inserting text in Vim
Inserting text in Vim

Normal Mode Navigation

Vim replaces arrow keys with h (left), j (down), k (up), l (right) to keep hands on the home row. Additional navigation shortcuts include: w – jump to the start of the next word. b – jump to the start of the previous word. e – jump to the end of the current word. 0 – move to the beginning of the line. $ – move to the end of the line. H, M, L – move to top, middle, bottom of the screen. Ctrl+u / Ctrl+d – scroll up/down half‑screen. gg – go to the first line; G – go to the last line.

Editing Commands in Normal Mode

Vim’s editing commands combine an operator with a motion: d{motion} – delete text defined by the motion (e.g., dw deletes a word, d$ deletes to end of line, dd deletes the whole line). c{motion} – change (delete then enter insert mode) (e.g., cw changes a word, cc changes an entire line). y{motion} – yank (copy) text (e.g., yw yanks a word, yy yanks a line). p – paste the most recent yank or delete after the cursor; P before. u – undo; Ctrl+r – redo.

Changing text with cc
Changing text with cc

Searching

To search within a file, use the forward slash followed by a regular expression: /pattern Press n to move to the next match and N for the previous match.

Searching strings in Vim
Searching strings in Vim

Visual Mode

Press v to start character‑wise visual selection, V for line‑wise, and Ctrl+v for block‑wise selection. Use the navigation keys ( h, j, k, l) to expand the selection, then apply commands such as y to yank or d to delete.

Block selection in Vim
Block selection in Vim

Command‑Line Mode

Enter command‑line mode by typing : in normal mode. Common commands include: :w – write (save) the file. :wq – write and quit. :q – quit. :q! – quit without saving. :e filename – edit another file. :help – open Vim’s help system.

Conclusion

Vim’s modal editing model, combined with powerful navigation and editing commands, enables fast, keyboard‑centric development. Mastering the basics—modes, insert techniques, navigation shortcuts, editing operators, searching, visual selection, and command‑line usage—provides a solid foundation for deeper Vim proficiency.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxcommand-linetext editorkeyboard shortcutsprogramming tools
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.