Playing Tag with Windows
Vim extends the vi tag functionality into windows by offering the same tag traversal mechanisms through multiple windows. Following a tag can also open a file in the associated place in a new window.
The tag windowing commands split the current window and follow a tag either to a file matching the tag or to the file matching the filename under the cursor.
:stag[!]
tag
splits the window to display the location for the tag found.
The new file containing the matched tag becomes the current window,
and the cursor is placed over the matched tag. If no tag is found, the
command fails and no new window is created.
Tip
As you become more familiar with Vim’s help system, you can
use this :stag
command to split
your way through the help system rather than jumping from file to
file in the same window.
^WJ
or ^W^J
splits the window and opens a window above the current window.
The new window becomes the current window, and the cursor is placed on
the matching tag. If there is no match on the tag, the command
fails.
^Wg]
splits the window and creates a new window above the current
window. In the new window, Vim performs the command :tselect
tag
,
where tag was the tag identifier under the
cursor. If no matching tag exists, the command fails. The cursor is
placed in the new window, and that new window becomes the current
window.
^Wg^J
works exactly like
^Wg]
, except that instead of performing :tselect
, it performs :tjump
.
^Wf
(or ^W^F
) splits the window and edits the filename underneath ...
Get Learning the vi and Vim Editors, 7th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.