没有仔细整理,先就这样,有的需要插件,这里只是一些配置;
"我的vim配置:
"linux-mint qian_cheng_long 20100910
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
" 在处理未保存或只读文件的时候,弹出确认
set confirm
"在命令行显示当前输入的命令
set showcmd
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" molokai(colorScheme)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:molokai_original = 0
so ~/.vim/colors/molokai.vim
"括号匹配
" inoremap ( ()<ESC>i
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap { <C-R>=Auto_brace('{')<CR>
inoremap } <c-r>=ClosePair('}')<CR>
inoremap [ []<ESC>i
inoremap ] <c-r>=ClosePair(']')<CR>
"" inoremap " ""<left>
"" inoremap ' ''<ESC>i
"function F()
" return 'fdas'
"endfunction
"为了解决在数组中的大括号问题
function Auto_brace(char)
if (a:char == '{')
if (search('[', 'nb', line(".")) != "") "若这一行前面存在'[',则执行
"return "a:"
return "{}\<left>"
else
"let line = getline('.');
"for char in line
"if (char == a:char)
"return {}\<left>"
"}
"endif
"endfor
"return b"
return "{\<cr>}\<esc>O"
endif
endif
endfunction
function ClosePair(char)
if getline('.')[col('.') - 1]==a:char
return "\<Right>"
else
return a:char
endif
endfunction
" Set to auto read when a file is changed from the outside
set autoread
"开启语法高亮
syntax enable
syntax on
"set gfn=Tlwg\ Typist\ 14
set guifont=文泉驿等宽微米黑\ 12
"set guifont=*
"配色方案
"colorscheme evening
"高亮当前行
set cursorline
"重新读取.vimrc
noremap ,s :source ~/.vimrc<cr>
"保存
set nobackup "不自动备份
noremap <a-s> :w<cr>
imap <a-s> <esc>:w<cr>
"tab=4
set ts=4
"统一缩进为4
set softtabstop=4
set shiftwidth=4
" 自动缩进
"set autoindent
filetype indent on
set cindent
" 为C程序提供自动缩进
set smartindent
"开启折行-按缩进
set foldmethod=indent
"编码设置
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,gb18030,gbk
"显示行号
set nu
"搜索忽略大小写
set ignorecase smartcase
"搜索逐字符高亮
set hlsearch
set incsearch
"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 为特定文件类型载入相关缩进文件
filetype indent on
" 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 回删
set backspace=2
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
" 启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 我的状态行显示的内容(包括文件类型和解码)
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\% [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set statusline=%2*%n%m%r%h%w%*\ %F\ %1*[FORMAT=%2*%{&ff}:%{&fenc!=''?&fenc:&enc}%1*]\ [TYPE=%2*%Y%1*]\ [ROW=%2*%03l%1*/%3*%L(%p%%)%1*]\ [COL=%2*%03v%1*]\ [ASCII=%03.3b]\ [HEX=0x%02.2B]
hi User1 guifg=Gray
hi User2 guifg=Red
hi User3 guifg=White
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline guibg=peru
elseif a:mode == 'r'
hi statusline guibg=blue
else
hi statusline guibg=black
endif
endfunction
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline guibg=orange guifg=white
hi statusline guibg=black
set laststatus=2 "总是显示状态栏
"if version >= 700
" au InsertEnter * hi StatusLine guibg=#818D29 guifg=#FCFCFC gui=none
"au InsertLeave * hi StatusLine guibg=#EEEEEE guifg=#363636 gui=none
"endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"taglist设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 让taglist单独在一个标签页输出
let Tlist_Show_One_File=1
" 不同时显示多个文件的 tag ,只显示当前文件的
let Tlist_Show_One_File=1
" 如果 taglist 窗口是最后一个窗口,则退出 vim
let Tlist_Exit_OnlyWindow=1
"让当前不被编辑的文件的方法列表自动折叠起来
let Tlist_File_Fold_Auto_Close=1
"显示taglist菜单
let Tlist_Show_Menu=1
let s:TlistIsOpened=0
nmap <F3> :Tlist<cr>
imap <F3> :Tlist<cr>
let Tlist_Use_Right_Window = 1
"""""""""""""""""""""""""""""""""""""""""""""""
"winmanager设置
"""""""""""""""""""""""""""""""""""""""""""""""
"wm开启和关闭winmanager
map <c-w><c-t> :WMToggle<cr>
"设置界面分割
"let g:winManagerWindowLayout='NERDTree|TagList,BufExplorer'
"let g:winManagerWindowLayout = "FileExplorer|TagList,BufExplorer"
"设置winmanager的宽度,默认为25
"let g:winManagerWidth = 30
""在进入vim时自动打开winmanager
"let g:AutoOpenWinManager = 1
"退出缓冲区时,自动退出vim
"let Tlist_Exit_OnlyWindow=1
"""""""""""""""""""""""""""""""""""
"ctags设置
"""""""""""""""""""""""""""""""""""
noremap <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q<CR>
imap <C-F12> <ESC>:!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q<CR>
set autochdir
set tags+=./tags,tags,../tags,../../tags
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"omni
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let OmniCpp_DefaultNamespaces = ["std"]
let OmniCpp_GlobalScopeSearch = 1 " 0 or 1
let OmniCpp_NamespaceSearch = 1 " 0 , 1 or 2
let OmniCpp_DisplayMode = 1
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 0 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_ShowPrototypeInAbbr = 1
let OmniCpp_ShowAccess = 1
set completeopt=longest,menu
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"using vimgdb mapping
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"run macros/gdb_mappings.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"authorinfo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:vimrc_author='QianChenglong'
let g:vimrc_email='qian_cheng_long@163.com'
let g:vimrc_homepage='waiting...'
nmap ,au :AuthorInfoDetect<cr>
set list " 显示tab和换行
set listchars=tab:>-,trail:- "tab 显示成>-,结尾处的空格显示-
"make session
"noremap mks :wa<cr>:mksession! ~/.session/session.vim<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Session setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap mks :wa<cr>:SaveSession<cr>
let g:session_default_to_last = 1
"Toggle Menu and Toolbar
set guioptions-=m
set guioptions-=T
map <silent> <c-F2> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>
\endif<CR>
if expand("%:t") == ".vimrc"
imap "<tab> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<cr>
endif
""""""""""""""""""""""""""""""
" BufExplorer
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0 " Do not show default help.
let g:bufExplorerShowRelativePath=1 " Show relative paths.
let g:bufExplorerSortBy='mru' " Sort by most recently used.
let g:bufExplorerSplitRight=0 " Split left.
let g:bufExplorerSplitVertical=1 " Split vertically.
let g:bufExplorerSplitVertSize = 30 " Split width
let g:bufExplorerUseCurrentWindow=1 " Open in new window.
autocmd BufWinEnter \[Buf\ List\] setl nonumber
"设置最大列数,超出后自动换行
set textwidth=80
"set verbose=9
"每次保存文件时,自动更新tags
"autocmd BufWritePost *.cpp,*.c,*.h :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q
"启动时最大化
autocmd GUIEnter * winsize 167 60
"so ~/.vim/plugin/supertab.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 使用F2去开/关NERDTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let NERDTreeWinPos = "left"
imap <F2> <esc>:call NerdTree()<cr>
nmap <F2> :call NerdTree()<cr>
let s:NerdIsOpened=0
function! NerdTree()
if(s:NerdIsOpened==0)
NERDTree
let s:NerdIsOpened=1
else
NERDTreeClose
let s:NerdIsOpened=0
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Cscope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set cscopequickfix=s-,c-,d-,i-,t-,e-
"find . -name "*.h" -o -name "*.c" -o -name "*.cpp" > cscope.files
"cscope -bkq -i cscope.files
if has("cscope")
"指定用来执行 cscope 的命令,这里不一定是/usr/bin/cscope,你自己得找到这个位置
set csprg=/usr/bin/cscope
"先搜索tags标签文件,再搜索cscope数据库
set csto=1
"使用|:cstag|(:cs find g),而不是缺省的:tag
set cst
"会显示文件路径的最后 3 个部分,包括文件名本身。
set cspc=3
"不显示添加数据库是否成功
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
"添加cscope数据库
cs add cscope.out
endif
"显示添加成功与否
set csverb
endif
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>
" 每次写入时,自动更新cscope数据库
"autocmd BufWritePost *.cpp,*.c,*.h :!cscope -Rbq
map <F12> :!cscope -Rbq<cr>
imap <F12> <esc>:!cscope -Rbq<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Supertap
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-x><C-o>"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ShowFunc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"map \sf <Plug>ShowFunc
"map! \sf <Plug>ShowFunc
if &filetype == "cpp" || &filetype == "c"
so ~/.vim/syntax/cpp.vim
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" complete setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
inoremap <c-]> <C-X><C-]>
inoremap <C-F> <C-X><C-F>
"inoremap <C-D> <C-X><C-D>
inoremap <C-L> <C-X><C-L>
inoremap <C-P> <C-X><C-P>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vimgdb
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set previewheight=12 " set gdb window initial height
"run macros/gdb_mappings.vim " source key mappings listed in this document
"set asm=0 " don't show any assembly stuff
"set gdbprg=gdb_invocation " set GDB invocation string (default 'gdb')
"map <F8> :bel 30vsplit gdb-variables<cr>
"map <F9> :!close<Esc>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vimlite
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map ;<F5> :VLWorkspaceOpen<CR>
map ;<F6> :wa<CR>:VLWBuildAndRunActiveProject<CR>
map ;<F7> :VLWDbgStart<CR>:Cmapkeys<CR>
map ;<F8> :VLWRunActiveProject<CR>
" 保存文件时, 自动 Parse 该文件
let g:VLWorkspaceParseFileAfterSave = 1
let g:VLWorkspaceSaveAllBeforeBuild = 1
let g:VLWorkspaceActiveProjectHlGroup = 'SpecialKey'
" 与上面的选项一起工作, 仅自动 Parse 头文件, 因为符号一般在头文件定义,
"源文件的实现的信息一般没什么用
" 需要强制 Parse 当前文件的话, 用 :VLWParseCurrentFile 命令
let g:VLWorkspaceNotParseSourceAfterSave = 1
imap<silent> ,, <esc>
map<silent> ,, <esc>