Vim
About
According to the official Vim website, "Vim is a highly configurable text editor for efficiently creating and changing any kind of text. It is included as "vi" with most UNIX systems and with Apple OS X."
Basic Usage
The syntax for Vim is pretty straightforward. You can edit files by running vim filename
to open the file with Vim, but if the file doesn't exist Vim will create one for you. Once you're in the editor, press i
to start inserting text. After you're finished editing the file, press the escape key and then enter :wq
to save the file. If you need to exit out of the file, press escape and enter :q
, and if you need to exit without saving press escape and type :q!
.
Other than that, there isn't much more that you need to know. For more advanced tips, check out the Vim Tips Wiki.
NOTICE: Please make sure that you have permission to write to the directory that you're editing the file in. If you don't check and make sure, you won't be able to save the file and will lose whatever changes you made.
Common Problems
Can't open file for writing
This problem occurs when you don't have permission to write to the file. To fix this, press the escape key and type :q!
to quit without saving. Then, run the same command again but prefixed with sudo
.