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.


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.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.