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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Trending

  • The Self-Hosting Math Changed While We Were Still Arguing About Sovereignty
  • Constrained Decoding Models Explained: Encoders, Decoders and When to Use Them
  • AI-Powered CI Test Failure Triage
  • Member Spotlight: Shai Almong

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Sep. 18, 18 · Code Snippet
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
52.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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