ctags
Basics
Ctags is a tool that makes it easy to navigate large source code projects. It provides some of the features that you may be used to using in Eclipse or other IDEs, such as the ability to jump from the current source file to definitions of functions and structures in other files.
For full info refer this link, https://courses.cs.washington.edu/courses/cse451/10au/tutorials/tutorial_ctags.html
Commands
cd $REPO_ROOT
ctags -R *
In vim
:! ctag -R *
Add the tags file to vimrc
echo "set tags=tags,../tags,TAGS,$REPO_ROOT/tags" >> ~/.vimrc
- Restart vim
- Go to a variable or function where you want to jump to definition
- Place cursor on functions
- Press: Ctrl-]
- vim will jump to the definition of that tag/function
- Press: Ctrl-t
- vim will get back to original position
- Every time you press Ctrl-], vim will create a tags stack
- You can decent to any number of tags and get back to original position using Ctrl-t
How to install ctags from source
wget -nc http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
wget -nc https://github.com/universal-ctags/ctags/archive/refs/heads/master.zip -O ctags.zip
tar xf pkg-config-0.29.2.tar.gz
cd ./pkg-config-0.29.2
./configure --prefix="$HOME/.local" --with-internal-glib
make
make install
cd ..
unzip -qo ctags.zip
cd ctags-master
export ACLOCAL_PATH="/usr/share/aclocal"
# The reason for setting ACLOCAL
./autogen.sh
./configure --prefix="$HOME/.local"
make
make install
Error: configure.ac:32: error: must install pkg-config 0.18 or later before running ./autogen.sh
Solution https://askubuntu.com/a/468895/817213
Reference and reading materials
For full info refer this link, https://courses.cs.washington.edu/courses/cse451/10au/tutorials/tutorial_ctags.html