vim (Vi IMproved) editor
Introduction to vim
vim stands for Vi IMproved. vim editor is an advanced (enhanced) version of default vi editor in linux. It is very useful for the programmers. The improvements in vim editor can be clearly seen in the handling of tags and writing of programs.
Default it is not installed in the linux system, you have to download it from the internet using the following command in linux terminal.
How to install & open?
To install vim, run following command with sudo.
$ sudo apt-get install vim
Once, vim installed successfully, you can use it.
You can get information about the vim editor by typing vim command.
To open/create file in vim, just type the $ vim file-name and hit enter.
The vim editor will open; see the following snap shot (it is the screen shot of vim editor).
commands that can make vim very useful to you
||Indent all file contents
When you want to indent all your source code in a proper indent, just press gg=G (small g, small g, equal and capital G).
||Indent current block
Bring the cursor at the starting braces of code and press % (shift + 5). Current block’s code will be indented in a proper format.
||switch into visual mode
This command convert vim, from text to GUI (visual) mode, where you can easily edit file’s contents. If you want to copy and paste, you can select the lines (that you want to copy) and press y to copy and press p to paste copied lines at the current cursor location.
This command allows you to edit in files in diff mode, here you can compare and edit more than one files.
$ vimdiff file1 file2
Most viewed pages
- My personal website.
Keywords (like Linux, Java, Oracle etc) used in this website are the trademarks of their respective owners/company. This website is not affiliated to any company. The tutorials are designed by includehelp Team with the help of well known books and other online resources. These Tutorials are free for all, for learning purposes only. Enjoy learning:)
Copyright © 2015 - 2016. All Rights Reserved.