ctags不支持js,vim党怎么玩? 然后就有人开发了个jstags...
1.安装:
npm install -g git+https://github.com/ramitos/jsctags.git
2.在你的开发目录执行shell脚本
find . -type f -iregex ".*\.js$" -not -path "./node_modules/*" -exec jsctags {} -f \; | sed '/^$/d' | LANG=C sort > tags
解释:
1.查找当前路径下以.js结尾的文件
2.排除路径node_midules
3.执行jstags -f给这些查找到的文件
4.删除空行
5.设置语言环境为C
6.然后排序
7.定向到tags文件
(感谢linux群友 Permission denied 朋友提供解释)
3.如果你的代码友jsx后缀名(react党?)(可选),执行脚本
find . -type f -iregex ".*\.jsx$" -not -path "./node_modules/*" -exec jsctags {} -f \; | sed '/^$/d' | LANG=C sort >> tags
---2018年11月07日11:45:58
最近发现之前两个命令执行后,vim搜tags会有bug(提示你tags没排序),建议把2,3步命令换成一条命令执行(tags删掉)
find . -not -path "./node_modules/*" |egrep "\.jsx?$" |xargs jsctags {} -f \; | sed '/^$/d' | LANG=C sort > tags
或
find -E . -regex ".*\.jsx?" -exec jsctags {} -f \; | sed '/^$/d' | LANG=C sort >> tags
---
4.快试试你的快捷键把
ctrl + ]
ctrl + o
ctrl + i
ctrl + p