Tip #7: Jumping to the start and end of a code block
tip karma |
Rating 66/37, Viewed by 4165
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
February 24, 2001 17:59 |
|
complexity: |
|
basic |
author: |
|
Yegappan |
|
as of Vim: |
|
5.7 |
To jump to the beginning of a C code block (while, switch, if etc),
use the [{ command.
To jump to the end of a C code block (while, switch, if etc),
use the ]} command.
The above two commands will work from anywhere inside the code
block.
To jump to the beginning of a parenthesis use the [( command.
To jump to the end of a parenthesis use the ]) command.
To get more help on these commands, do
:help [{
:help ]}
:help [(
:help ])
<< Using the % key |
Jumping to the declaration of a local/global variable >>
Additional Notes
[email protected],
June 14, 2002 17:55
|
related to these motion command are [[ and ]]
[[
sections backward or to the previous '{' in the first column.
]]
sections backward or to the previous '{' in the first column.
[]
sections backward or to the previous '}' in the first column.
This has specially help me in jumping to the top of the functions and jumping from one function to the next function.
May be our coding convention played a part in this
|
Anonymous,
June 30, 2004 12:31
|
To jump to the beginning/end of a function that does not have a "{" in the first column, there is a work around in the VIM documentation.
Try ":help [[" and search for "map" in that text.
|
anon,
March 27, 2006 12:58
|
hi, what's the different between this and just searching "/ or ?" for the braces?
i thought this might be a smarter search, but "[{" will still matchin open curlies inside a comment.
|
|