Include file searches (
:help include-search) can be useful for navigating around large files. You can do things like:
- List the first line that contains the keyword under the cursor
- List all lines that match the keyword under the cursor
- Jump to the first line that contains the keyword under the cursor
Although this feature is tailored to C by default, it can be adapted to work with other languages with some configuration.
Download jquery-2.0.3.js and open it in Vim. Move the cursor to line 35 (
35G) then move the cursor over
document and press
[i. At the bottom of the screen you'll see
document = window.document, -- Vim is indicating the first match of this keyword from the start of the file. You can also try
]i which shows the next match from the cursor's position.
Now move to line 38 and press
[I (that's capital
_jQuery. You will see two matches this time.
This is pretty basic, but you'll notice this feature doesn't really need any specific programming language parsing support. The commands we've looked at will even work with plain text.
What makes this feature useful for C programmers, though, is it will search through included files as well. To configure how Vim loads files from the file system, you need to use
:set include="some pattern". See
:set 'include' for help.
.vimrc example uses
'suffixesadd' to make Vim figure out the Node's module loading rules.
So, remember that
[I can be useful, and can be bent to your will.