No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
In order to create or update the cscope database in current directory, the following key mapping would help a bit: |
In order to create or update the cscope database in current directory, the following key mapping would help a bit: |
||
− | <script> |
||
nmap <F11> :!find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files ; cs kill -1<CR>:cs add cscope.out<CR> |
nmap <F11> :!find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files ; cs kill -1<CR>:cs add cscope.out<CR> |
||
− | </script> |
||
In the above mapping, I use "find" to collect the C/C++ source code files and (re)create the cscope database; then "kill -1" to kill '''all''' cscope database connections and finally, the newly created "cscope.out" database is added by "cs add cscope.out". |
In the above mapping, I use "find" to collect the C/C++ source code files and (re)create the cscope database; then "kill -1" to kill '''all''' cscope database connections and finally, the newly created "cscope.out" database is added by "cs add cscope.out". |
Revision as of 08:50, 21 June 2007
Tip: Automatically create and update cscope database
Created: 06-21-2007 Complexity: intermediate Author: Zhaojun WU Version:
In order to create or update the cscope database in current directory, the following key mapping would help a bit:
nmap <F11> :!find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files ; cs kill -1<CR>:cs add cscope.out<CR>
In the above mapping, I use "find" to collect the C/C++ source code files and (re)create the cscope database; then "kill -1" to kill all cscope database connections and finally, the newly created "cscope.out" database is added by "cs add cscope.out".
There are two limitations in this key mapping:
1. the current directory should be the root path of the project 2. I don't know how to get the current cscope data connection number, so that I use "kill -1" to kill "all" cscope database connections, since actually I always only create one connections in one vim instance. It would be not practical if you are using multiple data connections in one vim instance.