Ubuntu16.04 installation configuration and use Ctags

Source: Internet
Author: User
Tags function definition

Ubuntu16.04 installation configuration and use Ctags

by Chriszz

Ctags can be used to define jumps in functions in vim. ubuntu16.04 under the default ctags is very old and very old ctags, almost moldy version (5.9~svn20110310-11), get rid of it, install Universal-ctags!

Moldy Exuberant-ctags.

Come on, let's see what happens with the default ctags.

See what Ctags packages are available in apt

aptitude search ctags

Query Result:

V Ctags                                                                                                                                            -                                                                                                                        V ctags:i386                                                                                                                                            -                                                                                                                   I exuberant-ctags -Build tag file indexes of source code Definiti                                                                                                              ONS p exuberant-ctags:i386 -Build Tag file Indexes of source code DEfinitions P Geany-plugin-ctags -Ctags PL                                                                                                                     Ugin for Geany                                                                                                           P geany-plugin-ctags:i386                                                                                                                     -Ctags plugin for Geany                                                                                                      P Libparse-exuberantctags-perl                                                                                                            -Exuberant Ctags parser for Perl                                      P libparse-exuberantctags-perl:i386                                                           -Exuberant Ctags parser for Perl           

Only Exuberant-ctags is the correct name for apt to install the ctags version.

View Exuberant-ctags Version Information

dpkg -l exuberant-ctags

Query Result:

Desired=Unknown/Install/Remove/Purge/Hold| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)||/ Name                                                           Version                              Architecture                         Description+++-==============================================================-====================================-====================================-==================================================================================================================================ii  exuberant-ctags                                                1:5.9~svn20110310-11                 amd64                                build tag file indexes of source code definitions

See where the version number is 5.9~svn20110310-11, has not been updated for 7 years. Such a bag, moldy for 7 years, throw it:

sudo apt remove exuberant-ctags -y
Installation of fresh Universal-ctags

What is Universal-ctags? A maintained ctags implementation, Https://ctags.io, a responsible ctags implementation, open source on GitHub and continuously updated and maintained.

Don't say more, install it quickly:

cd /tmpgit clone https://github.com/universal-ctags/ctags./autogen.sh./configure --prefix=/opt/software/universal-ctags  # 我的安装路径。你按自己的情况调整。make -j8sudo make install

Update the Ctags executable file to the system path? No, I choose how to create a link:

# 如果你装了emacs-snapshot,那么现在的ctags命令实际上链接到了/usr/bin/ctags-snapshot,要先删除链接文件:# sudo rm /usr/bin/ctags# 然后,把新编译安装的universal-ctags链接过来:sudo ln -s /opt/software/universal-ctags/bin/ctags /usr/bin/ctags
Configuring Ctags in Vim

The key sentence is: set tags=./.tags;,.tags , put in the Vim configuration file.

Can be configured directly with my VIM:

cd /tmpgit  clone --depth=1  https://github.com/amix/vimrc.git  ~/.vim_runtimesh  ~/.vim_runtime/install_awesome_vimrc.shgit  clone  https://github.com/zchrissirhcz/dotfilescp  dotfiles/my_configs.vim  ~/.vim_runtime/
Using Ctags
cd ~/work/opencv   # 随便进入到一个你的c++工程目录ctags -R .  #递归地生成.tags文件

Then use shift+] and shift+t in vim to jump into and out of the function definition.

enjoy!

Ubuntu16.04 installation configuration and use Ctags

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.