top of page
Search
  • Writer's pictureJoseph

Using Vim and Ctags to Manage Large Projects

The usual workflow in developing an HPC application is to develop the code in local machines and then run the completed application in an HPC machine. There is no scenario where the entire application is directly developed on an HPC machine.


One problem I have encountered is that when you scale an application in an HPC machine, there may arise issues that were not encountered in the local machine. So you will have to make tweaks to your application in the HPC machine. This is a problem as the development tools you have used in the local machine may not be available in the HPC machine. For instance, I use VSCode to manage all my C/C++ projects as it makes it easy to peek into function definitions (and much more). While VSCode has a remote option to access the remote HPC machine, it is not as smooth as using it locally.


Ctags are one way you can manage large projects. While this is not an alternative to advanced code editors, this can enhance your Vim usage. You can install Ctags using the following:

sudo apt-get update && sudo apt-get install -y exuberant-ctags

Then tun the command

 ctags --recurse=yes 

from your root project directory, to generate tags. If you want to exclude some directories from the tag generation you can use the --exclude flag to specify these directories.

ctags --recurse=yes --exclude=.git --exclude=./build

If these directories apply to all your projects you can specify them in the ~/.ctags file. Where the .ctags file will have the entries

--recurse=yes
--exclude=.git
--exclude=./build

Now if you want to open a file with that has the definition of the function print_task(), you can do that using

vim -t print_task

Now if you want to open a file that has the definition of the function print_task(), you can do that using

find_task();
print_task();
execute_task();

and you want to go to the file that has the function definition of print_task() then you use the vim command

:tag find_task

This will take you to the file that has the definition of the function print_task(). If you just want to preview and not go to the file that has the definition of find_task() you can use the command

:ptag find_task

and the preview window can be closed using

:pc


13 views0 comments

Recent Posts

See All

Automate Workflow Using VSCode

VSCode is a very popular tool to manage large projects in C/C++. One of the main advantages of VSCode is we can automate workflows that we use often. There are many articles available on how you can d

bottom of page