DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Trending

  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • Building AI-Powered Java Applications With Jakarta EE and LangChain4j
  • Building a Spring AI Assistant With MCP Servers: A Step-by-Step Tutorial
  • Persistent Memory for AI Agents Using LangChain's Deep Agents
  1. DZone
  2. Coding
  3. Tools
  4. Install ctags, Create tags, Browse in Vim

Install ctags, Create tags, Browse in Vim

In this post, an experienced developer demonstrates how to install ctags on Ubuntu 16.04.3, create tags, and browse the code in vim.

By 
Zach Pfeffer user avatar
Zach Pfeffer
·
Sep. 18, 18 · Code Snippet
Likes (1)
Comment
Save
Tweet
Share
52.7K Views

Join the DZone community and get the full member experience.

Join For Free

Install

Type sudo apt-get install ctags.

Note: this command will actually install exuberant-ctags on Ubuntu 16.04.3. Here's the output

zpfeffer@z:~/code$ sudo apt-get install ctags
[sudo] password for zpfeffer: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'exuberant-ctags' instead of 'ctags'
The following NEW packages will be installed:
  exuberant-ctags
0 upgraded, 1 newly installed, 0 to remove and 46 not upgraded.
Need to get 126 kB of archives.
After this operation, 341 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 exuberant-ctags amd64 1:5.9~svn20110310-11 [126 kB]
Fetched 126 kB in 0s (294 kB/s)     
Selecting previously unselected package exuberant-ctags.
(Reading database ... 194228 files and directories currently installed.)
Preparing to unpack .../exuberant-ctags_1%3a5.9~svn20110310-11_amd64.deb ...
Unpacking exuberant-ctags (1:5.9~svn20110310-11) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up exuberant-ctags (1:5.9~svn20110310-11) ...
update-alternatives: using /usr/bin/ctags-exuberant to provide /usr/bin/ctags (ctags) in auto mode
update-alternatives: using /usr/bin/ctags-exuberant to provide /usr/bin/etags (etags) in auto mode

Create tags File

1. cd into the directory of code.

2. Type ctags -R.

Browse Code

1. Open a .c, .h or .cpp file with vim.

2. Put your cursor on a symbol.

3. Type <C-]> to jump to a symbol. Keep typing to build a stack of symbols.

4. Type <C-t> to jump back. Pop back to where you last were. Works until the stack of symbols is exhausted.

References

  • Vim and Ctags by Andrew Stewart at [link]
  • The Vim logo is from [link]

Additional Info

What is are ctags? (asked on Reddit at [link])

From: http://ctags.sourceforge.net/whatis.html ctags is the program that generates an index also called tags. These tags are "language objects found in source files that allow these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object)."

Vim (text editor)

Published at DZone with permission of Zach Pfeffer. See the original article here.

Opinions expressed by DZone contributors are their own.

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook