`
yaojingguo
  • 浏览: 201703 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Use vim, cscope and ctags for linux 2.6 kernel source code (memo)

阅读更多

 

Install cscope

 

sudo apt-get install cscope

 

Generate cscope.files

 

LNX=/home/jing/data/road/linux/linus
cd /    
find  $LNX                                                                \
-path "$LNX/arch/*" ! -path "$LNX/arch/x86*" -prune -o               \
-path "$LNX/Documentation*" -prune -o                                 \
-path "$LNX/scripts*" -prune -o                                       \
-path "$LNX/drivers*" -prune -o                                       \
      -name "*.[chxsS]" -print >$LNX/cscope.files

 

 Generate the Cscope database

   cscope -b -q -k

 Copy the following text to .vimrc

 

if has("cscope")
  set csprg=cscope
  set csto=0
  set cst
  set nocsverb
  " add any database in current directory
  if filereadable("cscope.out")
      cs add cscope.out
  " else add database pointed to by environment
  elseif $CSCOPE_DB != ""
      cs add $CSCOPE_DB
  endif
  set csverb

  " mapping	
  nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
	nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
	nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
	nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
	nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
	nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
	nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
	nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif

  Script to generate tags:

 

#!/bin/bash
LNX=.
ctags -R \
  --exclude=arch/alpha \
  --exclude=arch/arm \
  --exclude=arch/avr32 \
  --exclude=arch/blackfin \
  --exclude=arch/c6x \
  --exclude=arch/cris \
  --exclude=arch/frv \
  --exclude=arch/h8300 \
  --exclude=arch/hexagon \
  --exclude=arch/ia64 \
  --exclude=arch/m32r \
  --exclude=arch/m68k \
  --exclude=arch/microblaze \
  --exclude=arch/mips \
  --exclude=arch/mn10300 \
  --exclude=arch/openrisc \
  --exclude=arch/parisc \
  --exclude=arch/powerpc \
  --exclude=arch/s390 \
  --exclude=arch/score \
  --exclude=arch/sh \
  --exclude=arch/sparc \
  --exclude=arch/tile \
  --exclude=arch/um \
  --exclude=arch/unicore32 \
  --exclude=arch/xtensa \
  --exclude=Documentation \
  --exclude=scripts \
  --exclude=drivers \
  $LNX
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics