Wikia

Vim Tips Wiki

Show tags in a separate preview window

Talk0
1,610pages on
this wiki
Tip 840 Printable Monobook Previous Next

created 2005 · complexity basic · author Alan Klietz · version 6.0


I love using exuberant ctags (especially ctags -R). But I dislike how the show-tag-under-cursor command (Control-]) replaces the current buffer and loses my cursor position. Instead I want to view the tag definition in a separate 'preview' window so I can, for example, view a C/C++ type declaration while coding a call.

Add the following to your vimrc file:

nnoremap <C-]> <Esc>:exe "ptjump " . expand("<cword>")<Esc>

This will make Control-] pop open a window and show the tag there. The :ptjump command shows the tag in a preview window without changing the current buffer or your cursor position.

This is especially handy for referencing C/C++ function declarations while entering code.

CommentsEdit

See :help CTRL-W_g}.


You can even look up tags by staring at the code:

:au! CursorHold *.[ch] nested call PreviewWord()

The CursorHold triggers and calls PreviewWord() if your cursor hasn't moved for sometime. Useful for reading new code.


If you want to search in include files, see :help CTRL-W_i.


Advertisement | Your ad here

Around Wikia's network

Random Wiki