文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>vim编辑环境全制造

vim编辑环境全制造

时间:2010-09-20  来源:kevin33643

ubuntu下vim+ctags+cscope+各种插件 取代 samba+winxp+sourceinsight

首先

sudo apt-get install ctags cscope cscope-indexer vim-full

记住ctags和cscope的两个命令

ctags -R

cscope -Rbkq

-R: 在生成索引文件时,搜索子目录树中的代码

-b: 只生成索引文件,不进入cscope的界面

-k: 在生成索引文件时,不搜索/usr/include目录

-q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度
下面大部分参考http://blog.csdn.net/wooin/archive/2007/10/31/1858917.aspx
我的.vimrc

set encoding=utf-8
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set termencoding=utf-8
set mouse=a
set guifont=Luxi\ Mono\ 9 " 设置字体,字体名称和字号
set tabstop=4 " 设置tab键的宽度
set backspace=2 " 设置退格键可用
set nu! " 显示行号
set vb t_vb= " vim进行编辑时,如果命令错误,会发出一个响声,该设置去掉响声
"set wrap " 自动换行
"set nowrap " 不自动换行
set linebreak " 整词换行
set whichwrap=b,s,<,>,[,] " 光标从行首和行末时可以跳到另一行去
"set list " 显示制表符
"set listchars = tab:>-,trail:- " 将制表符显示为'>---',将行尾空格显示为'-'
set listchars=tab:.\ ,trail:. " 将制表符显示为'. '
set autochdir " 自动设置目录为正在编辑的文件所在的目录
set hidden " 没有保存的缓冲区可以自动被隐藏
set scrolloff=5
"--------------------------------------------------------------------------------
" 查找/替换相关的设置
"--------------------------------------------------------------------------------
set hlsearch " 高亮显示搜索结果
set incsearch " 查询时非常方便,如要查找book单词,当输入到/b时,会自动找到
" 第一个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的
" 单词,依次类推,进行查找时,使用此设置会快速找到答案,当你
" 找要匹配的单词时,别忘记回车
set gdefault " 替换时所有的行内匹配都被替换,而不是只有第一个
"--------------------------------------------------------------------------------
" 状态栏相关的设置
"--------------------------------------------------------------------------------
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
set laststatus=2 " always show the status line
set ruler " 在编辑过程中,在右下角显示光标位置的状态行
"--------------------------------------------------------------------------------
" 编程相关的设置
"--------------------------------------------------------------------------------
set completeopt=longest,menu " 关掉智能补全时的预览窗口
filetype pluginindenton " 加了这句才可以用智能补全
set tags=tags;
syn on " 打开语法高亮
set showmatch " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号
set smartindent " 智能对齐方式
set shiftwidth=4 " 换行时行间交错使用4个空格
set autoindent " 自动对齐
set " 设置自动缩进
colorscheme evening
"--------------------------------------------------------------------------------
" 代码折叠
"--------------------------------------------------------------------------------
"set foldmarker={,}
"set foldmethod=marker
set foldmethod=syntax
set foldlevel=100 " Don't autofold anything (but I can still fold manually)
"set foldopen-=search " don't open folds when you search into them
"set foldopen-=undo " don't open folds when you undo stuff
"set foldcolumn=4

下面在各种插件

TagList
     http://www.vim.org/scripts/script.php?script_id=273
那里面列出了当前文件中的所有宏, 全局变量, 函数名等

在vimrc中添加

let Tlist_Show_One_File=1
 let Tlist_Exit_OnlyWindow=1



WinManager
http://www.vim.org/scripts/script.php?script_id=95
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>



QuickFix 窗口(vim自带)
:set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <F6> :cn<cr>
nmap <F7> :cp<cr>



cscope
0 或 s     查找本 C 符号(可以跳过注释)
1 或 g     查找本定义
2 或 d     查找本函数调用的函数
3 或 c     查找调用本函数的函数
4 或 t     查找本字符串
6 或 e     查找本 egrep 模式
7 或 f     查找本文件
8 或 i     查找包含本文件的文件
在vimrc中添加
nmap cs :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap cg :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap cc :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap ct :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap ce :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap cf :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap ci :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap cd :cs find d <C-R>=expand("<cword>")<CR><CR>



MiniBufExplorer
管理多标签
let g:miniBufExplorerMoreThanOne=0




到这看代码我觉得已经很ok了,vim的基本操作只能靠平时积累习惯了

SuperTab
http://www.vim.org/scripts/script.php?script_id=1643
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"

再加上之前已经在.vimrc中写了的
filetype plugin indent on
打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu
关掉智能补全时的预览窗口

现在基本写代码也很ok了
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载