step 4: vim csope === ###### tags: `vim` `cscope` ### install sudo apt install cscope ### setting 在project根目錄 cscope -Rbqk 會產生 cscope.out, cscope.po.out, cscope.in.out 或是創建 cscope.sh,將以下寫入 cscope.sh,並執行該腳本 : #!/bin/sh find ./ -name "*.c" -o -name "*.h" -o -name "*.cpp" > cscope.files cscope -Rbqk -i cscope.files 進入vim, cmd輸入 :cs add cscope.out ### usage 在cmd輸入: 1.找C label,即找func name、macro、enum等出現的地方 :cs find s <func or var name> 2.找func、macro、enum等define的地方,類似ctags的功能 :cs find g 3.找callee :cs find d 4.找caller :cs find c 5.找指定的string :cs find t: 6.找egrep模式 :cs find e 7.find and open the file,similer to the 'find' in vim :cs find f 8.找含本file的文 :cs find i ### vimrc 將noremap開頭的行加入~/.vimrc內 此時整個vimrc如下 (set tags要install ctags) : execute pathogen#infect() syntax on filetype plugin indent on set tags=/home/user/arm-os-from-scratch/tags set number set hlsearch set bg=dark hi Comment ctermfg=green nmap zs :cs find s <C-R>=expand("<cword>")<CR><CR> nmap zg :cs find g <C-R>=expand("<cword>")<CR><CR> nmap zc :cs find c <C-R>=expand("<cword>")<CR><CR> nmap zd :cs find d <C-R>=expand("<cword>")<CR><CR> nmap zt :cs find t <C-R>=expand("<cword>")<CR><CR> nmap ze :cs find e <C-R>=expand("<cword>")<CR><CR> nmap zf :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap zi :cs find i <C-R>=expand("<cfile>")<CR><CR> 代表光標停在function name處按下zs等同於在vim cmd輸入":cs find s <func name>" ### 其他設定 set hlsearch 為高亮搜索, 關閉搜索的高亮, 輸入 :nohls hi Comment ctermfg=green 將註解設定為綠色 ### hightlight plugin https://github.com/octol/vim-cpp-enhanced-highlight install: cd ~/.vim/bundle git clone https://github.com/octol/vim-cpp-enhanced-highlight ### ref https://angledark0123.pixnet.net/blog/post/51919594 https://shaynechen.gitlab.io/vim-cscope/ https://ivan7645.github.io/2016/07/12/vim_to_si/
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up