ctags

ctags is a tool that makes it easy to navigate large source code projects. ctags will create tags file which contain all the symbols refrence which is used for code navigation.

How to install

sudo apt install universal-ctags

Init ctags

 ctags -R

Init ctags with exclude directory

ctags -R --exclude=src

ctags with vim

  • Init ctags first

    Run ctags recursively on your project-root-directry to generate the tags file.

    ctags -R
    
  • To Search specific tag and open its definition

    vim -t <tag>
    

    or open any source file in vim

    vim <filename>
    
  • Keyboard Command to use ctags after opening file

    • Jump to the tag under cursor
      ctrl+]
      
    • Jump back, or Jump back in the tag stack
      ctrl+t
      
    • To search for particular tag
      :ts
      
    • To jump to the next definition for the last tag
      :tn
      
    • To jump to the previous definition for the last tag
      :tp
      
    • To list all of the definitions of the last tag
      :ts
      
    • To List multiple possible entry of tag while ctrl+]
      :nnoremap <C-]> g<C-]>
      

Refrences



©2023-2024 rculock.com