A Beginner's Guide to Vim: The Powerful Text Editor
Vim (Vi Improved) is an enhanced version of the classic Vi editor. It’s:
✔ Fast – Works entirely in the terminal.
✔ Modal – Uses different modes for different tasks.
✔ Extensible – Highly customizable with plugins.
Most Linux/macOS systems come with Vim preinstalled. To check:
vim --version
If not installed:
sudo apt install vim
brew install vim
vim filename.txt
Esc
(to ensure you're in Normal mode).:q
and press Enter
(quit).:q!
to force quit.Vim has multiple modes, but the most important are:
i
(insert) or a
(append).Esc
.:
.Use these keys to move around:
h
←, j
↓, k
↑, l
→w
– Move to next word.b
– Move to previous word.0
– Start of line.$
– End of line.gg
– Top of file.G
– Bottom of file.i
– Insert before cursor.a
– Append after cursor.o
– New line below.O
– New line above.x
– Delete character under cursor.dw
– Delete word.dd
– Delete entire line.u
– Undo.Ctrl + r
– Redo.From Normal mode:
:w
– Save.:wq
or :x
– Save and quit.:q!
– Quit without saving./search_term
– Search forward.?search_term
– Search backward.n
– Next match.N
– Previous match.yy
– Copy (yank) a line.p
– Paste (put) after cursor.P
– Paste before cursor.:set number
/ :set nonumber
.:syntax on
.:split
(horizontal), :vsplit
(vertical).Vim might feel intimidating at first, but with practice, it becomes second nature. Start with these basics, and gradually explore more advanced features like macros, plugins, and custom configurations.
Pro Tip: Run vimtutor
in your terminal for an interactive guide!
Happy editing!
Would you like me to add anything specific, like advanced commands or customization tips? Let me know!