|author||Joe Rayhawk <firstname.lastname@example.org>||2013-07-08 07:19:56 +0000|
|committer||Joe Rayhawk <email@example.com>||2013-07-08 07:19:56 +0000|
moin2mdwn: convert page Development/Documentation/UsingCtags
Diffstat (limited to 'Development/Documentation/UsingCtags.mdwn')
1 files changed, 30 insertions, 0 deletions
diff --git a/Development/Documentation/UsingCtags.mdwn b/Development/Documentation/UsingCtags.mdwn
new file mode 100644
@@ -0,0 +1,30 @@
+## Using ctags to find functions
+Finding functions in X is hard. One way to search for the actual definition of a data type is to grep the source directory and then open the file. This can take forever, especially when you don't quite know where to look for.
+However, vim's support for ctags makes it easier. It is possible to create a tags file for the whole system and then just use it from within vim. That way, in vim you only have to go to the occurence of the data type, press CTRL+] and it will open the matching definition. With CTRL+T you jump back to the original file.
+I created my tags file somewhere in my .vim directory.
+[[!format txt """
+$> mkdir .vim/tags/
+$> cd .vim/tags/
+$> ctags -R /usr/include/* /path/to/X/source/code
+ctags will create a file "tags" in the current directory ($HOME/.vim/tags in this case). This way I got pretty much all defintions I need at the moment.
+Now you need to tell vim to include this file. Add the following line to your $HOME/.vimrc.
+[[!format txt """
+On your next startup of vim, everything will be available with CTRL+]. If you use tags heavily, you will find CTRL+G helpful. It shows the name of the file in the current buffer.
+A recommendation is to write a little script to update your ctags and run it as a cron job every night. Your computer will not be very responsive while recursively searching for ctags in a multi-GB directory.
+This can be a hazardous setup as the ctags are absolute. If you are working on two different source trees (i.e. two releases of the same software), using CTRL+ ] will jump to the functions as defined in ctags. So you might be editing the wrong source tree.