vim
a widely used text editor among Unix users
What is vim?
Historically, there are two widely used text editors among Unix users: vi
and emacs
.
vim
is the most recent version of vivim
stands for vi improvedvim
andemacs
tend to have long arguments about which is better.- These arguments are pointless and tedious.
- They are both good; they just have different design tradeoffs.
If you want to learn about emacs instead of vim, visit the Emacs Page on this website. Since this page is about vim, we won’t mention emacs further.
Quick Reference Guides
- Vim wiki http://vim.wikia.com/wiki/Category:Getting_started
- Vim tutorial http://vim.wikia.com/wiki/Tutorial
How To
- Line-numbers on the side:
:set nu
- To make this persist between invocations of vim, see Vim: Customization
-
What do
:w
,:wq
, and:wq!
mean? :w
means “write”. Hit “Escape” and type in the character sequence to write your edits.:wq
means “write and quit”. Hit “Escape” and type in the character sequence to write and quit from the Vim environment.:q!
means “quit without saving”.
And a bonus:
:u
means “undo”.
Finding and Replacing
- To go to a specific line number:
:[LINE_NUMBER]
- For instance, if I was trying to go to line 181 in a file, I would enter
:181
- For instance, if I was trying to go to line 181 in a file, I would enter
- To search for a character string:
/[STRING]
- Note that you may need to use the escape character
\
before any special characters
- Note that you may need to use the escape character
- To search/replace (e.g. change
old
tonew
):- To replace the first encountered instance of a string:
:%s/old/new/
- To replace all instances of a string:
:%s/old/new/g
- To replace the first encountered instance of a string: