You can check whether vim is installed by opening your unix shell (Terminal) and typing:
vim 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 For Debian,
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.
vim testfile 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:
:23 And this will send you to line 23. To go to the beginning of the file type:
gg 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
x This will delete the character immediately after the cursor. Another method of deletion is by typing
i to enter insert mode, and then simply hitting the delete or backspace button. To delete a line, type
dd 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
10x This will delete 10 characters forward the cursor. To delete 15 lines, type
15dd 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:
:w To quit type:
:q To save and quit type:
:wq 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.