Wikia

Vim Tips Wiki

Changes: Show tags in a separate preview window

Edit

Back to page

m (dodgy and category)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=837
 
|previous=837
 
|next=842
 
|next=842
|created=January 3, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=Alan Klietz
 
|author=Alan Klietz
Line 21: Line 21:
 
</pre>
 
</pre>
   
This will make Control-] pop open a window and show the tag there. The <tt>:ptjump</tt> command shows the tag in a preview window without changing the current buffer or your cursor position.
+
This will make Control-] pop open a window and show the tag there. The <code>:ptjump</code> 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.
 
This is especially handy for referencing C/C++ function declarations while entering code.

Latest revision as of 05:51, July 13, 2012

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.


Around Wikia's network

Random Wiki