Master Vim: 26 Keyboard Shortcuts to Supercharge Your Coding Efficiency
Learn how Vim’s modal editing, essential commands, and customizable configuration can dramatically boost your coding speed on Linux, covering everything from basic navigation and text manipulation to advanced file management and one‑click setup for a powerful, keyboard‑centric development environment.
Efficiency Revolution: Vim—Rebuilding Your Code Universe with 26 Keyboard Keys
In the world of code, efficiency is a perpetual pursuit. Vim, hailed as the "king of efficiency" in the Linux ecosystem, uses the 26 alphabet keys as its core to reshape code editing.
What is Vim?
Vim (Vi IMproved) is a highly configurable text editor, originally released as an improvement over the classic Vi editor. It runs on most Unix‑like systems (Linux, macOS) and also supports Windows. Vim’s design philosophy is modal editing, using distinct modes (Normal, Insert, Visual, Command‑line) to perform editing tasks efficiently.
Why Choose Vim?
Extreme efficiency : Almost all operations are keyboard‑driven, eliminating frequent mouse switches.
Highly customizable : Rich configuration options and a vibrant plugin ecosystem let users tailor the editor to their workflow.
Cross‑platform : Consistent experience on Linux, macOS, and Windows.
Steep learning curve but high payoff : Mastery yields productivity gains unmatched by most other editors.
Core Modes
Normal Mode
The default mode where all navigation and editing commands are issued.
Insert Mode
Enter Insert mode with a, i or o to start inserting text.
Command‑line Mode
Press : to enter Command‑line mode, where you can execute commands such as :w (save) and :q (quit).
Basic Operations
Enter Vim
Run vim filename to open a file in Vim.
Mode Switching
Switch between modes using the keys mentioned above; press Esc to return to Normal mode.
Exit Vim
In Normal mode, type ZZ to save and exit. In Command‑line mode, use :wq to save and quit, or :q! to force quit without saving.
Command‑Mode Commands
Cursor Movement
Basic moves : h (left), j (down), k (up), l (right).
Specific positions : G (end of file), $ (end of line), ^ (beginning of line), w (next word start), e (next word end), b (previous word start), 5l (move 5 columns right), gg (start of file).
Screen moves : Ctrl+b (page up), Ctrl+f (page down), Ctrl+u (half‑page up), Ctrl+d (half‑page down).
Delete Text
Character delete: x (delete under cursor), 6x (delete six characters), X (delete left of cursor), 20X (delete twenty characters left).
Line delete: dd (delete current line), 3dd (delete three lines).
Copy and Paste
Copy characters: yw (yank word), 3yw (yank three words).
Copy lines: yy (yank current line), 5yy (yank five lines).
Paste: p (paste after cursor).
Cut: dd also cuts the line into the unnamed register.
Replace
Single character: r followed by the new character.
Replace mode: R (replace until Esc ).
Toggle case: ~ on a character.
Undo and Redo
Undo: u (repeat to undo multiple changes).
Redo: Ctrl+r (repeat to redo undone changes).
Change
cw(change word), c3w (change three words).
Jump to Specific Line
Ctrl+g(show current line number). 15G (move to line 15).
Command‑line Mode Commands
Save File
Enter :w to write the file.
Exit
:q(quit), :q! (force quit without saving). :wq (save and quit).
Force Actions
!q(force quit), !w (force write, overriding read‑only).
Set Line Numbers
:set nu(show line numbers). :set nonu (hide line numbers).
Multi‑file Operations
In Command‑line mode, vs filename opens multiple files side‑by‑side; Ctrl+w w jumps the cursor to the next split.
Vim Configuration
Location of the Config File
Configuration is typically stored in the home directory file .vimrc. Create it with touch .vimrc if it does not exist, then edit with vim .vimrc.
Common Settings
syntax on " automatic syntax highlighting
set nu " show line numbers
set tabstop=4 " set tab width to 4 spaces
set cursorline " highlight current line
...One‑Click Automated Setup
For a quick C++ development environment, run the following command (note: do not use the root account and it only supports CentOS 7 x86_64):
curl -sLf https://gitee.com/HGtz2222/VimForCpp/raw/master/install.sh -o ./install.sh && bash ./install.shLinux users on other distributions can search for alternative Vim plugins and configurations.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
