I'm trying to write a vim function to update ctags
and cscope
databases. I'm trying to save the vim variable projectRoot
in environment variable then expand this enviroment variable in the find
command. But it is not working. Here is my try:
let projectRoot="/mnt/hgfs/projects/myProject/"
function! UpdateTagDB()
:cd /
:execute("let ProRoot=".g:projectRoot)
:find $ProRoot -name '*.c' -o -name '*.h' > $ProRoot/cscope.files<cr>
:execute("cd ".g:projectRoot)
:!ctags -R .<cr>
:!cscope -bR<cr>
endfunction
nnoremap <F5> :call UpdateTagDB()
When hitting F5
, it gives me:
line 2:
E15: Invalid expression: /mnt/hgfs/projects/myProject/
line 3:
E345: Can't find file "$ProRoot -name '*.c' -o -name '*.h' > $ProRoot/cscope.files<cr>" in path
What is missing and how to get it to work?