Boost Your Coding Speed: Essential Vim Tips for Beginners
This guide introduces essential Vim shortcuts and .vimrc configurations—covering line numbering, indentation, file navigation, editing, searching, commenting, and integrating external content—to help beginners work more efficiently with the powerful editor.
Vim is a popular editor for developers; by configuring commands and shortcuts you can work faster. This article provides beginner-friendly Vim tips to improve efficiency.
1. Configure .vimrc
When I first used Vim I wasted time on indentation; you can modify .vimrc to enable line numbers, auto‑indentation, syntax highlighting, etc.
Create a .vimrc in your home directory and add the following settings:
set number
set autoindent
set nowrap2. Exit without closing terminal
Saving and quitting is easy: press ESC to enter normal mode, type :wq to write and quit.
:wqTo quit without saving, press ESC, then :q!.
:q!3. Delete lines
Instead of using Backspace, use normal mode commands:
dd # delete current line
5dd # delete 5 lines starting from current line
dG # delete from current line to end of file4. Copy and paste
To copy a line or a block of code:
Press ESC, move cursor to start of desired text, press V to select line (or extend selection), press y to copy or d to cut, move cursor to target location, press p to paste after cursor or P before.5. Undo and redo
In normal mode, press u to undo and Ctrl+r to redo.6. Commenting code
To comment lines:
Press Ctrl+v to enter visual block mode, move cursor to select column, press I, type comment symbol (e.g., #), then ESC.To uncomment:
Press Ctrl+v, select the comment characters, press d or x to delete them.7. Search
Enter / followed by the search term and press Enter. Use n for next match, N for previous.
/word-to-be-searched8. Read external file into Vim
Use :read followed by filename.
:read readme.md9. Read command output into Vim
Use :read !command to insert command output.
:read !ls -l10. Jump to last edit
Press g; in normal mode to return to the position of the last change.11. Move to top or bottom of file
Press gg to go to the top, G to go to the bottom.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.
