Showing posts with label VIM Editore cool tricks.. Show all posts
Showing posts with label VIM Editore cool tricks.. Show all posts

20 March, 2011

Useful tips in VIM Editore.

1. If you want to split the screen horizontally give command
:split
If you want to split the screen vertically give command
:vsplit
If you want to open an new/other exiting file in splited window give command
:new filename for horizontal window
:vnew filename for vertical window.
If you want to quit all window give command
:qall for quitting without saving the changes
:wqall for quitting with saving the changes
You can use normal quitting command for one particular splitted window like
q,wq
To move between the splitted window , use ctrl+ww

2. Folding techniques:
You can fold a block of code of a long file. The block can be anything like (),{},[]
or may be some code between the lines.
For example:
Suppose this is your code:
#include
.........................
.......
int main(void)
{
----
----
----
for(;;){

-----
-----
}
}

To fold the brackets {} of for loop, keep the cursor at opening bracket of the for loop and then use zfa} command. It will make a fold till the closing of the corresponding bracket. This technique also works form backward.
It means you can keep the cursor at the closing bracket and use command zfa{ .
For closing and opening the folds, move the cursor at the fold and use command za
If you want to fold the codes between particular lines , Use command
:beginning_line,closing_line fold
Give a space between closing line and fold command.You can also use fo instead of fold.

For more details about this folding option just visit the link.
http://www.linux.com/archive/feature/114138