You can check whether vim is installed by opening your unix shell (Terminal) and typing:
If it's installed you'll see a welcome screen with a few basic commands.
If it's not installed, you'll want to install it. On Red Hat style of Linux you can use:
yum install vim
apt-get install vim
If these don't apply, you may have to find vim installation instructions for your specific computer.
Navigate to your home directory and create a test file.
Using the vim commands will both open an existing file or create a new file if the specified filename doesn't already exist.
When vim opens, you are in command mode. In order to start entering or editing text, simple type i.
At the bottom of the screen you should see:
-- INSERT --
To get out of insert mode, simply type
One of the benefits of vim is that you are able to quickly navigate through the file.
To jump to a line number (i.e. line 33) type:
And this will send you to line 23.
To go to the beginning of the file type:
To go to the end of the file type:
shift + G
There are many more commands to help you quickly navigate without using the arrow keys.
To delete single a single character you can type
This will delete the character immediately after the cursor.
Another method of deletion is by typing
to enter insert mode, and then simply hitting the delete or backspace button.
To delete a line, type
This will delete the line where the cursor is.
Once you learn plenty of vim commands, you'll want to apply a command to multiple characters or lines.
For instance, to delete 10 characters type
This will delete 10 characters forward the cursor.
To delete 15 lines, type
To copy 100 lines starting from the cursor, type
Many people forget the most basic and important part of vim.
To save your file type:
To quit type:
To save and quit type:
If you've made changes you don't want to keep and need to force the file to quit without saving type:
Find a good vim cheat sheet to help you learn more commands! It will take a while memorize all of the commands, but the more you learn the more efficient you will be.