Fandom

Vim Tips Wiki

Show tags in a separate preview window

Redirected from VimTip840

1,624pages on
this wiki
Add New Page
Talk0 Share

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.

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.


Also on Fandom

Random Wiki