Another Japan in the World

Jun Aruga's blog, who lived in Japan, Singapore, live in Czech Republic. Mainly about IT and travel.

Read Ruby source - 3. Prepare tools: ctags

Install nice tools to read C source code on Mac.

This time is ctags.

Install

ctags is installed on Mac by default. But it is BSD version, does not have the enough feature.
So, install GNU ctags by homebrew.

$ which ctags
/usr/bin/ctags

It is installed to /usr/local/bin

$ brew install ctags
$ ls /usr/local/bin/ctags
/usr/local/bin/ctags@

Read forcely /usr/local/bin/ctags

$ vi ~/.bashrc
...
alias ctags='/usr/local/bin/ctags'
...

$ . ~/.bashrc

How to use

Create a tags file.

$ cd $GIT_DIR/ruby/

$ ctags -R .

$ ctags -a -R /usr/include

$ ls -l tags
-rw-r--r--  1 jun.aruga  staff  26164537 Dec 10 01:07 tags

Open one c file by vim

$ vi main.c

Operation. at vim command mode.

  • Look into: Ctrl+] (After moving cursor to function, variable, macro, and etc)
  • List up possible files, select, and look into: g, Ctrl+]
  • Look back: Ctrl+t
  • Open split new window to look into: Ctrl+w, ]

Available file types

$ ctags --list-languages
Ant
Asm
Asp
Awk
Basic
BETA
C
C++
C#
Cobol
DosBatch
Eiffel
Erlang
Flex
Fortran
HTML
Java
JavaScript
Lisp
Lua
Make
MatLab
OCaml
Pascal
Perl
PHP
Python
REXX
Ruby
Scheme
Sh
SLang
SML
SQL
Tcl
Tex
Vera
Verilog
VHDL
Vim
YACC

That's all.

Remove all ads