Vim+Ctags+Cscope配置

  • 安装
aptitude install vim ctags cscope
  • 配置
vim /etc/vim/vimrc
 
 
" 设定默认解码  
set fenc=utf-8  
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 

" history文件中需要记录的行数  
set history=100  


" 在处理未保存或只读文件的时候,弹出确认  
set confirm


" 不要备份文件(根据自己需要取舍)  
set nobackup 


" 不要生成swap文件,当buffer被丢弃的时候隐藏它  
setlocal noswapfile  
set bufhidden=hide 


" 不要使用vi的键盘模式,而是vim自己的
set nocompatible 


" 打开语法高亮
syntax on


" 配色方案(可用 :highlight 查看配色方案细节)
" 这里有各种配色方案:
" http://vimcolorschemetest.googlecode.com/svn/html/index-c.html
"colorscheme murphy
colorscheme desert
"colorscheme darkblue


" 显示行号
set number
 
" 打开自动缩进
set autoindent


" 使用 C/C++ 的缩进方式
set cindent


" 为 C 程序提供自动缩进
set smartindent


" 设置自动缩进长度为四个空格
set shiftwidth=4


" 按退格键时可以一次删掉 4 个空格
set softtabstop=4


" 设定 tab 键长度为 4
set tabstop=4


" 将 tab 展开为空格
set expandtab


" 强调匹配的括号
set showmatch


" 光标短暂跳转到匹配括号的时间, 单位是十分之一秒
set matchtime=2


" 侦测文件类型
filetype on
 
" 载入文件类型插件
filetype plugin on
 
" 为不同文件类型使用不用缩进
filetype indent on


" 去掉输入错误时的提示声音
set noerrorbells


" 右下角显示光标位置
set ruler


" 总是显示状态行
set laststatus=2


" 自定义状态行
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
"              | | | | |  |   |      |  |     |    |
"              | | | | |  |   |      |  |     |    +-- 当前列数
"              | | | | |  |   |      |  |     +-- 当前行数
"              | | | | |  |   |      |  +-- 当前光标位置百分比
"              | | | | |  |   |      +-- 使用的语法高亮器
"              | | | | |  |   +-- 文件格式
"              | | | | |  +-- 文件总行数
"              | | | | +-- 预览标志
"              | | | +-- 帮助文件标志
"              | | +-- 只读标志
"              | +-- 已修改标志
"              +-- 当前文件绝对路径


" 显示当前正在键入的命令
set showcmd


" 设置自动切换目录为当前文件所在目录,用 :sh 时候会很方便
set autochdir


" 随着键入即时搜索
set incsearch


" 有一个或以上大写字母时仍大小写敏感
set smartcase


" 代码折叠
"set foldenable


" 折叠方法
" manual 手工折叠
" indent 使用缩进表示折叠
" expr       使用表达式定义折叠
" syntax 使用语法定义折叠
" diff       对没有更改的文本进行折叠
" marker 使用标记进行折叠, 默认标记是 {{{ 和 }}}
"set foldmethod=indent


" 光标移动到buffer的顶部和底部时保持3行距离  
set scrolloff=3  
 
" 不要闪烁  
set novisualbell 


" Only do this part when compiled with support for autocommands.
if has("autocmd")


  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on


  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78


  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif
endif " has("autocmd")
使用
ctags -R *
cscope -Rbkq
vim -t <tags>
ctrl + ]
ctrl + o

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值