Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >vim+cscope看源码配置

vim+cscope看源码配置

原创
作者头像
johnazhang
发布于 2022-10-31 08:19:18
发布于 2022-10-31 08:19:18
7460
举报
文章被收录于专栏:Linux问题笔记Linux问题笔记

配置vim可参考https://blog.csdn.net/ywgdk/article/details/53607874等博客。

配置好后在想要看的源码目录执行脚本

代码语言:txt
AI代码解释
复制
find $1 -path $1/scripts* -prune -o -name *.[chxsS] -print > ./cscope.files
cscope -Rbkq

即可。

附我的vimrc配置如下

代码语言:txt
AI代码解释
复制
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CSCOPE settings for vim           
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" This file contains some boilerplate settings for vim's cscope interface,
" plus some keyboard mappings that I've found useful.
"
" USAGE: 
" -- vim 6:     Stick this file in your ~/.vim/plugin directory (or in a
"               'plugin' directory in some other directory that is in your
"               'runtimepath'.
"
" -- vim 5:     Stick this file somewhere and 'source cscope.vim' it from
"               your ~/.vimrc file (or cut and paste it into your .vimrc).
"
" NOTE: 
" These key maps use multiple keystrokes (2 or 3 keys).  If you find that vim
" keeps timing you out before you can complete them, try changing your timeout
" settings, as explained below.
"
" Happy cscoping,
"
" Jason Duell       jduell@alumni.princeton.edu     2002/3/7
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


" This tests to see if vim was configured with the '--enable-cscope' option
" when it was compiled.  If it wasn't, time to recompile vim... 
if has("cscope")

    """"""""""""" Standard cscope/vim boilerplate

    " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
    set cscopetag

    " check cscope for definition of a symbol before checking ctags: set to 1
    " if you want the reverse search order.
    set csto=0

    set nocscopeverbose
    " add any cscope database in current directory
    if filereadable("cscope.out")
        cs add cscope.out  
    " else add the database pointed to by environment variable 
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif

    " show msg when any other cscope db added
    set cscopeverbose  


    """"""""""""" My cscope/vim key mappings
    "
    " The following maps all invoke one of the following cscope search types:
    "
    "   's'   symbol: find all references to the token under cursor
    "   'g'   global: find global definition(s) of the token under cursor
    "   'c'   calls:  find all calls to the function name under cursor
    "   't'   text:   find all instances of the text under cursor
    "   'e'   egrep:  egrep search for the word under cursor
    "   'f'   file:   open the filename under cursor
    "   'i'   includes: find files that include the filename under cursor
    "   'd'   called: find functions that function under cursor calls
    "
    " Below are three sets of the maps: one set that just jumps to your
    " search result, one that splits the existing vim window horizontally and
    " diplays your search result in the new window, and one that does the same
    " thing, but does a vertical split instead (vim 6 only).
    "
    " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
    " unlikely that you need their default mappings (CTRL-\'s default use is
    " as part of CTRL-\ CTRL-N typemap, which basically just does the same
    " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
    " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
    " of these maps to use other keys.  One likely candidate is 'CTRL-_'
    " (which also maps to CTRL-/, which is easier to type).  By default it is
    " used to switch between Hebrew and English keyboard mode.
    "
    " All of the maps involving the <cfile> macro use '^<cfile>$': this is so
    " that searches over '#include <time.h>" return only references to
    " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
    " files that contain 'time.h' as part of their name).


    " To do the first type of search, hit 'CTRL-\', followed by one of the
    " cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope
    " search will be displayed in the current window.  You can use CTRL-T to
    " go back to where you were before the search.  
    "

    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>


    " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
    " makes the vim window split horizontally, with search result displayed in
    " the new window.
    "
    " (Note: earlier versions of vim may not have the :scs command, but it
    " can be simulated roughly via:
    "    nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>

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


    " Hitting CTRL-space *twice* before the search type does a vertical 
    " split instead of a horizontal one (vim 6 and up only)
    "
    " (Note: you may wish to put a 'set splitright' in your .vimrc
    " if you prefer the new window on the right instead of the left

    nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>


    """"""""""""" key map timeouts
    "
    " By default Vim will only wait 1 second for each keystroke in a mapping.
    " You may find that too short with the above typemaps.  If so, you should
    " either turn off mapping timeouts via 'notimeout'.
    "
    "set notimeout 
    "
    " Or, you can keep timeouts, by uncommenting the timeoutlen line below,
    " with your own personal favorite value (in milliseconds):
    "
    "set timeoutlen=4000
    "
    " Either way, since mapping timeout settings by default also set the
    " timeouts for multicharacter 'keys codes' (like <F1>), you should also
    " set ttimeout and ttimeoutlen: otherwise, you will experience strange
    " delays as vim waits for a keystroke after you hit ESC (it will be
    " waiting to see if the ESC is actually part of a key code like <F1>).
    "
    "set ttimeout 
    "
    " personally, I find a tenth of a second to work well for key code
    " timeouts. If you experience problems and have a slow terminal or network
    " connection, set it higher.  If you don't set ttimeoutlen, the value for
    " timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
    "
    "set ttimeoutlen=100

endif

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
vim配置总结[通俗易懂]
我的vim版本是8.1,这个版本可以在vim中直接调用terminal,并且自带的插件管理器。如果你不是8.1的vim版本,可能无法使用我下面的插件安装方法,需要自行百度下载一个插件管理器了。
全栈程序员站长
2022/08/31
1.7K0
超级强大的vim配置(vimplus)
最近在重新配置Vim,也在GitHub上找了三个star和fork数目很高的方案,在这里分享给大家: https://github.com/amix/vimrc - star 3,482 ; Fork
_gongluck
2018/03/13
29.9K2
超级强大的vim配置(vimplus)
vim开发环境配置
作为编辑器之神的vim,初安装时,就像十几岁的孩子,潜力无限但能力有限。所以当我们要充分开发它的潜能时,那么就不得不对vim进行扩展,也就是安装插件。(当然了,如果你不想定制自己所需要的插件,只是想一键安装,然后满足你几乎所有对vim的需求,那么你可以尝试spf13-vim github地址:https://github.com/spf13/spf13-vim) 下面介绍部分插件的安装,以满足基本的代码阅读或者项目开发的需求。
编程珠玑
2019/09/03
2K0
vim开发环境配置
vim配置IDE,下载压缩包即拥有轻巧且强大的文本编辑器
用 vim 也有一段时间了, 真心是越用越好用, 现已作为敲代码主力以及默认文本编辑器。
杨永贞
2022/04/13
7750
vim配置IDE,下载压缩包即拥有轻巧且强大的文本编辑器
一步步将vim改造成C/C++开发环境(IDE)
1、安装Vim和Vim基本插件 首先安装好Vim和Vim的基本插件。这些使用apt-get安装即可: lingd@ubuntu:~/arm$sudo apt-get install vim vim-scripts vim-doc 其中vim-scripts是vim的一些基本插件,包括语法高亮的支持、缩进等等。 vim中文帮助文档tar包下载地址: http://sourceforge.net/projects/vimcdoc/files/vimcdoc/ 解压后其中有个doc文件夹, 将其中的内容全部复制到~/.vim/doc, 或者vim安装目录下的doc目录中, 此时vim中的help信息已经是中文的了. 网页版中文帮助文档网址http://vimcdoc.sourceforge.net/doc/help.html 首页就时vim帮助文档的目录,阅读起来更方便有效、更有针对性! 2、Vim配置文件 Vim强大的功能,其来源基本上就两个地方:Vim插件以及Vim配置文件。 Vim本身的系统配置文件夹是在/usr/share/vim/和/etc/vim/两个文件夹下。一般情况下,我们不会去改变这两个文件夹下的配置文件,而是在用户文件夹/home/user(其中,user为用户名,我的用户名是lingd)下建立自己的配置文件。进入用户文件夹(/home/user/)之后,用gedit新建一个名叫.vimrc的文件: lingd@ubuntu:~/arm$ cd ~ lingd@ubuntu:~$ gedit .vimrc 注:使用gedit主要是为了方便大段大段的文字粘贴! 然后把下面的文字拷贝进这个文件之后保存:
bear_fish
2018/09/20
9.3K0
一步步将vim改造成C/C++开发环境(IDE)
让Vim打造成强大的IDE,附_vimrc的配置和使用
然后把_vimrc配置文件放到安装目录下。这个配置文件是之前别人写好的,用着有点儿问题特意改了下。稍后附件中会附带这个。直接能用。
杨永贞
2020/08/04
1.4K0
VIM配置文件vimrc
Ubuntu 默认情况下只安装tiny-vim , 只要运行 sudo apt-get install vim 安装完整的vim就好了
阳光岛主
2019/02/19
2.8K0
常用的vim配置,_vimrc文件
if has("gui_win32") source $VIMRUNTIME/vimrc_example.vim "source $VIMRUNTIME/mswin.vim set nocompatible "behave mswin " Remove menu, scroll bar and tools bar set guioptions-=m set guioptions-=r set guioptions-=T " Command ToggleView let s:view_
杨永贞
2020/08/04
1.2K0
Vim的配置说明
在网上参考了某大牛个vim配置,然后更改添加了一部分,形成了自己的配置,让Vim变的更强大。
xindoo
2021/01/21
1.1K0
vim常用设置—(.vimrc详细配置)[通俗易懂]
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
全栈程序员站长
2022/08/23
2.3K0
vim+cscope+ctags源码安装
首先安装cscope [root@cutbag sys]#tar jxvf cscope-15.7a.tar.bz2[root@cutbag sys]#cd cscope-15.7a[root@cutbag sys]#./configure --prefix=/usr&&make&&make install 然后安装vim [root@cutbag sys]#tar jxvf vim-7.2.tar.bz2 [root@cutbag sys]#GUI_INC_LOC="" GUI_LIB_LOC="" C
用户3765803
2019/03/05
1.5K0
VIM个性化配置(一)
只需在Home目录创建一个 ~/.vimrc 文件即可以配置 vim 了,如需安装插件,在 ~/.vim 目录下创建一个bundle文件夹,插件装在里面。(需安装 Vundle 插件管理器),将以下内容拷入~/.vimrc 文件中即可。
宋天伦
2020/07/27
1.4K0
用GVIM/VIM写Verilog——VIM配置分享「建议收藏」
在VIN中操作,为了使得双手脱离键盘,但是方向键距离手指较远,ESC同样,因此禁用掉方向键,同时使用jk代替ESC进入命令模式。 VIM中有三种模式:命令模式,输入模式,命令行模式,其map映射 在vim配置文件中经常会看到map、nmap、imap n ——表示在普通模式下生效。 v ——表示在可视模式下生效。 i ——表示在插入模式下效。 具体配置方式见上 这里为了满足大多数人的需求,在配置中将其注释掉,有需要的同学自行打开
全栈程序员站长
2022/11/11
5K0
用GVIM/VIM写Verilog——VIM配置分享「建议收藏」
君子善器之按行号跳转:用vim查阅verilog编译信息的一个小技巧
前段时间请求IT把Linux服务器上的vim升级到vim7.4,一个想法是可以用vim7.0之后加入的特性gF,可以实现跳转到光标所在文件的指定行,如果文件名后面跟着行号的话。这个命令很高效,不用记下行号,gf,然后输入行号,而是直接gF一步到位。
icsoc
2020/07/07
8530
Golang 语言--linux 下 go语言 vim设置
在linux下安装 vundle.vim,请参照https://github.com/VundleVim/Vundle.vim获取和配置 打开.vimrc,如果没有可以创建.vimrc,复制如下内容到.vimrc " An example for a vimrc file. "" Maintainer: Bram Moolenaar <Bram@vim.org> " Last change: 2014 Nov 05" " To use it, copy it to" for Unix and
李海彬
2018/03/21
2.5K0
为什么要选择Vim编辑器
基本上来说,你应该尽可能少的呆在插入模式里面,因为在插入模式里面 VIM 就像一个“哑巴”编辑器一样。很多新手都会一直呆在插入模式里面,因为这样易于使用。但 VIM 的强大之处在于他的命令模式!你会发现,在你越来越了解 VIM 之后,你就会花越来越少的时间使用插入模式了。
杨永贞
2020/08/04
1.4K0
为什么要选择Vim编辑器
好用到哭!8个技巧让Vim菜鸟变专家
Vim只不过是一个文本编辑器,但如果你曾见过真正的高手是如何使用vim的,你就会知道,这个软件出人意料地强大、高效、迅捷。对于高水平使用者而言,vim能够帮助其更清晰、明确地表达操作指令。一旦熟练掌握vim语言,使用者就能更加快速地和自己的电脑交流。
昱良
2019/10/21
8070
好用到哭!8个技巧让Vim菜鸟变专家
「个人vim插件+配置」
复制代码时执行`set paste`来取消自动缩进,再`set nopaste`恢复。
饶文津
2020/06/02
1K0
vim查找快捷键_vim搜索关键字命令
我们通常在vim下要查找字符串的时候, 都是输入 / 或者 ? 加 需要查找的字符串来进行搜索,比如想搜索 super 这个单词, 可以输入 /super 或者 ?super, 两者的区别是前者是从上往下搜索,后者是从下往上搜索。
全栈程序员站长
2022/11/09
3.1K0
vim查找快捷键_vim搜索关键字命令
Linux vimrc常见配置
vim博大精深,先看看有哪比较使用的vim插件 Linux 为源代码生成ctags: 1.sudo apt-get install ctags安装vim插件 2.cd到代码根目录,比如说cd ./linux-5.x.x 2.生成tags文件,根目录执行ctags -R xxx(xxx为需要生成tags的文件目录)
全栈程序员站长
2022/08/25
2.8K0
Linux vimrc常见配置
相关推荐
vim配置总结[通俗易懂]
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档