USR_29
*usr_29.txt* For IdeaVIM version 0.12.0. Last change: 2006 Nov 12
IdeaVIM USER MANUAL - by Rick Maddy
Moving through programs
The creator of Vim is a computer programmer. It's no surprise that Vim
contains many features to aid in writing programs. Jump around to find where
identifiers are defined and used. Preview declarations in a separate window.
There is more in the next chapter.
|29.1| Using tags
|29.2| The preview window
|29.3| Moving through a program
|29.4| Finding global identifiers
|29.5| Finding local identifiers
Next chapter: |usr_30.txt| Editing programs
Previous chapter: |usr_28.txt| Folding
Table of contents: |usr_toc.txt|
*29.1* Using tags
This information does not apply to IdeaVIM.
*29.2* The preview window
This information does not apply to IdeaVIM.
*29.3* Moving through a program
Since a program is structured, Vim can recognize items in it. Specific
commands can be used to move around.
MOVING IN CODE BLOCKS
In C code blocks are enclosed in {}
. These can get pretty long. To move to
the start of the outer block use the "[[" command. Use "]]" to find the end.
This assumes that the "{" and "}
" are in the first column.
The "[{" command moves to the start of the current block. It skips over
pairs of {}
at the same level. "]}" jumps to the end.
An overview:
function(int a)
+-> {
| if (a)
| +-> {
[[ |
| for (;;) --+
|
| +-> { |
| [{
| | foo(32);
| --+
|
| [{ | if (bar(a)) --+
| ]} |
+-- | +-- break;
| ]} |
|
| } <-+
| | ]]
+-- foobar(a) |
|
} <-+ |
} <-+
When writing C++ or Java, the outer {}
block is for the class. The next level
of {}
is for a method. When somewhere inside a class use "[m" to find the
previous start of a method. "]m" finds the next end of a method.
Additionally, "[]" moves backward to the end of a function and "][" moves
forward to the end of a function. The end of a function is defined by a "}"
in the first column.
int func1(void)
{
return 1;
+----------> }
|
[] | int func2(void)
| +-> {
| [[
| if (flag)
start +-- +-- return flag;
| ][
| return 2;
| +-> }
]] |
| int func3(void)
+----------> {
return 3;
}
Don't forget you can also use "%" to move between matching (), {}
and [].
That also works when they are many lines apart.
MOVING IN BRACES
The "[(" and "])" commands work similar to "[{" and "]}
", except that they
work on () pairs instead of {}
pairs.
[(
<--------------------------------
<-------
if (a == b && (c == d || (e > f)) && x > y)
-------------->
-------------------------------->
])
*29.4* Finding global identifiers
This information does not apply to IdeaVIM.
*29.5* Finding local identifiers
This information does not apply to IdeaVIM.
Next chapter: |usr_30.txt| Editing programs
Copyright: see |manual-copyright|