vim ctagsを使用すると、現在のファイルに含まれるboostヘッダファイルのプロパティジャンプが増加します.
2311 ワード
1. ~/.vimrcで増加
2.pythonスクリプト:
pythonスクリプトとして保存し、コードディレクトリでスクリプトを実行できます.
set tags+=~/.vim/systags
2.pythonスクリプト:
pythonスクリプトとして保存し、コードディレクトリでスクリプトを実行できます.
#!/usr/bin/python2
# coding: utf-8
import os
import sys
import re
g_boost_path = "/usr/local/include"
g_tags_cmd = "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/systags "
#
g_path_list = []
#boost
g_pre_boost_file_list = []
g_pre_sec_boost_file_list = []
def getPathFiles(rootDir):
list_dirs = os.walk(rootDir)
for root, dirs, files in list_dirs:
#for d in dirs:
# print os.path.join(root, d)
for f in files:
#print os.path.join(root, f)
if(f.endswith((".cpp", ".c", ".h", ".hpp"))):
abspath= os.path.join(root, f)
g_path_list.append(abspath)
def extractBoostFile(filePath, fileList):
file = open(filePath)
while 1:
lines = file.readlines(100)
if not lines:
break
for line in lines:
if line.startswith("#include") and -1 != line.find("", line)[0])
#print "dir: " + incPath
fileList.append(incPath)
pass
else:
continue
if __name__ == '__main__':
usrDir = ""
if len(sys.argv) < 2:
usrDir = "."
#print "Usage: getPathFiles path"
else:
usrDir = sys.argv[1];
topPath = os.path.abspath(usrDir)
if not os.path.isdir(topPath):
print "dir [" + sys.argv[1] + "] is't exist"
sys.exit(0)
getPathFiles(topPath)
for f in g_path_list:
extractBoostFile(f, g_pre_boost_file_list)
for f in g_pre_boost_file_list:
extractBoostFile(f, g_pre_sec_boost_file_list)
for i in g_pre_boost_file_list:
g_tags_cmd += (i + " ")
for i in g_pre_sec_boost_file_list:
g_tags_cmd += (i + " ")
if(not os.path.isfile("~/.vim/systags")):
os.system(r"touch ~/.vim/systags")
#print g_tags_cmd
os.system(g_tags_cmd)