This is for people who love VIM and also for people who hate VIM.
Some of you may be wondering what VIM is. Let me find the expansion, honestly I don't know.
Here you go:
Vim was created as an extended version of the vi editor, with many additional features designed to be helpful in editing program source code. Its full name is Vi IMproved.
- AND -
vi is a screen-oriented text editor written by Bill Joy in 1976 for an early BSD release. The name vi is derived from the shortest unambiguous abbreviation for the command visual in ex, the command in question switches the line editor ex to visual mode.
That is with the origin...
Ok, this is going to be a multipart series on various tips in using VIM Effectively.
- For VIM Experts, there may be some insights.
- For Novices, this will make you like VIM.
The Effective Use of VIM Series...
» » Effective Use of VIM - Part 1
» Effective Use of VIM - Part 2
» Effective Use of VIM - Part 3
» Effective Use of VIM - Part 4
» Effective Use of VIM - Part 5
== PART 1 ==
You can execute VIM by the command
It is better to use VIM than vi. You can just define,
and put it in your
.vimrcfile which stores all the options for VIM, it is in your home directory (
~). When VIM starts, it will get options from
.vimrc. You can also set options while inside VIM, but they will be lost once you exit VIM.
Lot of you may not know how to exit VIM. Here are some methods...
[ When you type
ESC, you will get to Normal mode. The commands starting with
:(colon) are given there. ]
:q- Exits VIM, if no changes yet to be saved.
:q!- Exits VIM, discarding unsaved changes.
ZZ(Just hold SHIFT and press z twice) - Save changes and Exit.
:wq- Save changes and Exit.
:x- Save changes if any and Exit.
CTRL + w, q(While holding CTRL, press w and then q, while pressing q, CTRL is not a must) - Exits VIM, if no changes yet to be saved.
Kill VIM !!! (why would I need that?)
VIM supports multiple windows inside the VIM window.
CTRL + w, s– Split Horizontally, reopen the same file in the new window.
CTRL + w, v– Split Vertically
CTRL + w, n– Opens a Blank Window
CTRL + w, c– Close active window
CTRL + w, o– Close all windows except the active one.
[ Closing window occurs only if there is no unsaved changes ]
Match Pairs - %
%is used to match paired characters.
If the cursor is at a starting brace, pressing % will take cursor to the matching closing brace, and vice versa.
This works for () (parantheses), /**/ (block comments) etc.
This is handy, can be used extensively with other commands like d (cut), y (copy) etc.
If you need to delete an entire function block, place cursor at either one of the braces and
d%will delete that full block.
You can use abbreviations for the most commonly used commands snippets.
iab <key> <expansion>
<key> is the string which should be expanded to <expansion>
You can either add in
.vimrcfile or give while editing.
<key><SPACE>will expand to <expansion><SPACE>
You can also use
<key><CTRL + ]>
Eg. : iab #i #include
- replace #i with #include
( I dont know a way to disable expanding for a particular instance only, you will have to manually edit that. )
Like it? Subscribe via RSS
You may have found out unique ways of doing things in VIM, pls share...