天天看点

ctags使用方法 ctags的使用方法1

分享一个ctags生成指定tags的脚本

这样对于浏览Android源码相当迅速

使用方法:

./ctags

即执行

ctags -R --verbose=no --languages=c,c++, --if0 bootable device frameworks hardware kernel* libcore vendor

将当前目录下的bootable device frameworks hardware kernel* libcore vendor文件夹(文件)递归检索其中的c,c++类型的文件(应为c++类型的文件包含.h后缀的文件,所以.h文件也会检索)且检索if 0包含的内容

./ctags c c++ java

即执行

ctags -R --verbose=no --languages=c,c++,java, bootable device frameworks hardware kernel* libcore vendor

将当前目录下的bootable device frameworks hardware kernel* libcore vendor文件夹(文件)递归检索其中的c,c++,java类型的文件(应为c++类型的文件包含.h后缀的文件,所以.h文件也会检索)且检索if 0包含的内容

脚本内容:

#!/bin/bash

tagspath="bootable device frameworks hardware kernel* libcore vendor"

see="--verbose=no"

if [ $# -eq 0 ];then

ctags -R $see --languages=c,c++ --if0 ${tagspath} &

echo ""

echo "ctags -R $see --languages=c,c++ --if0 ${tagspath} &"

echo ""

elif [ $# -gt 0 ];then

if [ $1 == "--help" ];then

echo ""

echo "[tagspath: ${tagspath}]"

echo "[print:    ${see}]"

echo "example: ./ctags codepath"

echo "example: ./ctags codepath c c++ java"

echo ""

else

ctags -R $see --languages=$1,$2,$3,$4,$5 --if0 ${tagspath} &

echo ""

echo "ctags -R $see --languages=$1,$2,$3,$4,$5 --if0 ${tagspath} &"

echo ""

fi

fi