Vim is my favorite text editor on the terminal. After playing for a little while with nano and emacs, I finally settled with vim for its simplicity (bare with me please). Although it can be customized and used like an entire IDE, I use it mostly for editing files on my servers and making small but crucial changes. Let's not get into Editor war and get started.
VIM text editor
This is not an extensive tutorial. Learning all the features vim has to offer is like trying to learn all the features Microsoft Excel has to offer. Although Excel is a powerful tool, the average user mostly use it to create a table. So this is what I will try to teach you: How to use it for your basic needs.
Installation
This will differ from system to system. This method should cover any flavor of Linux that uses aptitude (Debian Based). Open your terminal and enter this command:
sudo apt-get install vim
That's it really, you should have the latest version installed now.
Creating and editing files
Let's create a simple file:
vim simple.txt
This creates a new file but doesn't save it to disk yet. The file is now open and ready for editing.
Vim has different modes. In this tutorial we will use only two of them: The normal mode and the insert mode. When you open a file or start the program, you are in normal mode (sometimes called standard mode). You can always come back to this mode from other places by pressing the ESC key on the keyboard. In this mode you can navigate through the document and run some commands. Here are a few things to know:
Action | Description |
---|---|
Navigation: | You can use the arrow keys to move around or these keys:
|
Commands |
|
:32
Jump to line 32
This is all done while in normal mode. To start writing text in the document, we go into insert mode. you can enter the mode by pressing the i
key:
Insert mode
On the bottom of the editor it will say -- INSERT --
. While in this mode we can write text you want just like in a regular text editor. In order to save the document or run any command, we will have to exit insert mode and go back to the normal mode. Press the ESC
key for that.
That's all there is to vim really. You can use it now to modify files and settings in your machine.
Editing a file with vim
Comments
There are no comments added yet.
Let's hear your thoughts