您的位置:首页 > 其它

vim IDE平台-打造属于自己的配置

2015-08-23 22:08 399 查看
vim IDE平台-打造属于自己的配置

一、前言

目前工作环境基本以Linux为主,自然用到VIM也很多,很早就对如何提高VIM的使用效率有所研究,限于时间关系,也没做个系统记录和资料积累,时间久了又容易忘,好久没写文档了,算是对自己一个交代。本文所涉及的配置和插件在附件中有下载。

二、环境

开篇之前,有必要交代一下系统环境和常用软件版本。

操作系统: centos 6.2,2.6.32-431.el6.i686

git 版本: 3.2.29

yum版本: 1.8

vim版本 : 7.2.411

三、vim配置

3.1 基本配置

包括一些基本的语法,缩进,代码折叠,高亮模式,窗口分割等,具体如下:

call pathogen#infect()
set expandtab
set tabstop=4       " 设置tab键的宽度
set softtabstop=4
set shiftwidth=4
set backspace=2     " 设置退格键可用

set nu!             " 显示行号

set linebreak       " 整词换行

set whichwrap=b,s,<,>,[,]       " 光标从行首和行末时可以跳到另一行去

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 plugin indent on       " 加了这句才可以用智能补全

let OmniCpp_MayCompleteDot = 1 " autocomplete with
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popup window
let OmniCpp_GlobalScopeSearch=1 " enable the global scope search
let OmniCpp_DisplayMode=1 " Class scope completion mode: always show all members
let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the last column
let OmniCpp_ShowAccess=1
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

"set tags=./tags
"set tags+=/usr/include/c++/tags
set tags+=/usr/local/cpp_src/cpp

syn on              " 打开语法高亮

set showmatch       " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号

set smartindent     " 智能对齐方式

set shiftwidth=4    " 换行时行间交错使用4个空格

set autoindent      " 自动对齐

set cindent         "设置C/C++缩进方式
"set ai!             " 设置自动缩进

colorscheme desert

"--------------------------------------------------------------------------------

" 代码折叠

"--------------------------------------------------------------------------------

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

" 窗口操作的快捷键

"--------------------------------------------------------------------------------
"  垂直分割当前窗口
nmap wv     <C-w>v
" 关闭当前窗口
nmap wc     <C-w>c
" 水平分割当前窗口
nmap ws     <C-w>s

"###############################################################################

" The following is the Plugins' setting

"###############################################################################

"--------------------------------------------------------------------------------

" TagList :Tlist

"--------------------------------------------------------------------------------

let Tlist_Show_One_File=1

let Tlist_Exit_OnlyWindow = 1

"let Tlist_Use_Right_Window=1

"--------------------------------------------------------------------------------

" netrw 文件浏览器 :e <PATH>

"--------------------------------------------------------------------------------

"let g:netrw_winsize = 30       " 浏览器宽度

"--------------------------------------------------------------------------------

" QuickFix

"--------------------------------------------------------------------------------
" 切换到下一个结果
nmap <F6> :cn<cr>
" 切换到上一个结果
nmap <F7> :cp<cr>

"--------------------------------------------------------------------------------

" WinManager :WMToggle

"--------------------------------------------------------------------------------

let g:winManagerWindowLayout='FileExplorer|TagList'

"是nomal模式的命令,不是Ex模式的

nmap wm :WMToggle<cr>

"--------------------------------------------------------------------------------

" MiniBufExp

"--------------------------------------------------------------------------------

let g:miniBufExplMapWindowNavArrows = 1

let g:miniBufExplMapCTabSwitchBufs = 1

"--------------------------------------------------------------------------------

" cscope

"--------------------------------------------------------------------------------

cs add /home/src/cscope.out /home/src

:set cscopequickfix=s-,c-,d-,i-,t-,e-

:set cscopetag

" 按下面这种组合键有技巧,按了<C-_>后要马上按下一个键,否则屏幕一闪

" 就回到nomal状态了

" <C-_>s的按法是先按"Ctrl+Shift+-",然后很快再按"s"

nmap <C-_>s :cs find s <C-R>=expand("<cword>")<cr><cr> :cw<cr>

nmap <C-_>g :cs find g <C-R>=expand("<cword>")<cr><cr> :cw<cr>

nmap <C-_>c :cs find c <C-R>=expand("<cword>")<cr><cr> :cw<cr>

nmap <C-_>t :cs find t <C-R>=expand("<cword>")<cr><cr> :cw<cr>

nmap <C-_>e :cs find e <C-R>=expand("<cword>")<cr><cr> :cw<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> :cw<cr>

nmap <C-_>d :cs find d <C-R>=expand("<cword>")<cr><cr> :cw<cr>

"--------------------------------------------------------------------------------

" Grep

"--------------------------------------------------------------------------------

"直接按下<F3>键来查找光标所在的字符串

nnoremap <silent> <F3> :Rgrep<CR>

"--------------------------------------------------------------------------------

" A

"--------------------------------------------------------------------------------

nnoremap <silent> <F12> :A<CR>

" NERD_commenter

"--------------------------------------------------------------------------------

let NERD_c_alt_style = 1    " 将C语言的注释符号改为//, 默认是/**/

"nmap <F5> ,cc

"--------------------------------------------------------------------------------

" SuperTab :SuperTabHelp

"--------------------------------------------------------------------------------

let g:SuperTabRetainCompletionType = 2

let g:SuperTabDefaultCompletionType = "<C-X><C-O>"

"--------------------------------------------------------------------------------

" CVim :help csupport

"--------------------------------------------------------------------------------

let g:C_Comments = "no"         " 用C++的注释风格

let g:C_BraceOnNewLine = "no"   " '{'是否独自一行

let g:C_AuthorName = "Wen Qiuliang"

let g:C_Project="F9"

let g:C_TypeOfH = "c"           " *.h文件的文件类型是C还是C++

let g:user_emmet_settings = {
\  'php' : {
\    'extends' : 'html',
\    'filters' : 'c',
\  },
\  'xml' : {
\    'extends' : 'html',
\  },
\  'haml' : {
\    'extends' : 'html',
\  },
\}

" vim markdown config
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd
let g:vim_markdown_folding_disabled=1
let g:vim_markdown_frontmatter=1


View Code
6.2 插件

本文所涉及的所有插件都上传在github中,地址如下:

https://git.oschina.net/ballwql/vim-plugin.git


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: