" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
"禁止显示滚动条
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
"enconding
set encoding=utf-8
set fileencoding=chinese
set fileencodings=ucs-bom,utf-8,chinese
set ambiwidth=double
"支持符合编码语法的折叠
set foldmethod=syntax
"启动时打开所有折叠
set foldlevel=100
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" 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
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" 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).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
"Set mapleader
let mapleader = ","
"Fast reloading of the .vimrc
map <silent><leader>ss :source ~/.vimrc<cr>
"Fast editing of the .vimrc
map <silent><leader>ee :e ~/.vimrc<cr>
"imap ;; to esc
"设置omni-completion补全代码快捷键
imap<leader><TAB> <C-X><C-O>
"设置复制至剪切版
vnoremap<leader>y "+y
"设置从剪切版粘贴
nmap<leader>p "+p
"定义快速关闭,保存
nmap<leader>q :q<CR>
nmap<leader>w :w<cr>
"定义makefile快捷键
nmap<leader>m :make<cr>
nmap<leader>mf :e makefile<cr>
"
"When .vimrc is edited, reload it
autocmd! bufwritepost .vimrc source ~/.vimrc
"Platform
function! MySys()
if has("win32")
return "windows"
else
return "linux"
end if
endfunction
function! SwitchToBuf(filename)
"let fullfn = substitute(a:filename, "^\\~/", $HOME . "/", "")
"find in current tab
let bufwinnr = bufwinnr(a:filename)
if bufwinnr != -1
exec bufwinnr . "wincmd w"
return
else
"find in each tab
tabfirst
let tab = 1
while tab <= tabpagenr("$")
let bufwinnr = bufwinnr(a:filename)
if bufwinnr != -1
exec "normal " . tab ."gt"
exec bufwinnr . "wincmd w"
return
endif
tabnext
let tab = tab + 1
endwhile
"not exist, new tab
exec "tabnew " . a :filename
endif
endfunction
"Fast edit vimrc
if MySys() == 'linux'
"Fast reloading of the .vimrc
map <silent><leader>ee: call SwitchToBuf("~/.vimrc")<cr>
"When .vimrc is edited, reload it
autocmd! bufwritepost .vimrc source ~/.vimrc
elseif MySys() == 'windows'
"Set helplang
set helplang = cn
"Fast reloading of the _vimrc
map <silent><leader>ss :source ~/_vimrc<cr>
"Fast editing of _vimrc
map <silent><leader>ee :call SwithTobuf("~/_vimrc")<cr>
"When _vimrc is edited, reload it
autocmd! bufwritepost _vimrc source ~/_vimrc
endif
"For windows version
if MySys() == 'windows'
source $VIMRUNTIME/mswin.vim
behave mswin
endif
"Display numbers
set nu
"Forbid backup
set nobackup
set nowritebackup
"""""""""""""""""""""""""""""""""""""
"Tag list(ctags)
"""""""""""""""""""""""""""""""""""""
if MySys() == "windows"
let Tlist_Ctags_Cmd = 'ctags'
elseif MySys() == "linux"
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
endif
let Tlist_Show_One_File = 1 "不能同时显示多个文件的tag,只能显示当前的
let Tlist_Exit_OnlyWindow = 1 "如果Tlist是最后一个窗口,则退出vi
let Tlist_Use_Right_Window = 1
"Colorscheme
colorscheme zenburn
""""""""""""""""""""""""""""
"netrw setting
""""""""""""""""""""""""""""
let g:netrw_winsize = 30
nmap <silent><leader>fe :Sexplore!<cr>
"Restore cursor to file position in previous editing session
set viminfo='10,\"100,:20,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Session options
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set sessionoptions-=curdir
set sessionoptions+=sesdir
""""""""""""""""""""""""""""""
" winManager setting
""""""""""""""""""""""""""""""
let g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList"
let g:winManagerWidth = 30
let g:defaultExplorer = 0
nmap <C-W><C-F> :FirstExplorerWindow<cr>
nmap <C-W><C-B> :BottomExplorerWindow<cr>
nmap <silent> <leader>wm :WMToggle<cr>
""""""""""""""""""""""""""""""
" 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
""""""""""""""""""""""""""""""
" lookupfile setting
""""""""""""""""""""""""""""""
let g:LookupFile_MinPatLength = 2 "最少输入2个字符才开始查找
let g:LookupFile_PreserveLastPattern = 0 "不保存上次查找的字符串
let g:LookupFile_PreservePatternHistory = 1 "保存查找历史
let g:LookupFile_AlwaysAcceptFirst = 1 "回车打开第一个匹配项目
let g:LookupFile_AllowNewFiles = 0 "不允许创建不存在的文件
nmap <silent> <leader>lk :LookupFile<cr>
nmap <silent> <leader>ll :LUBufs<cr>
nmap <silent> <leader>lw :LUWalk<cr>
" lookup file with ignore case
function! LookupFile_IgnoreCaseFunc(pattern)
let _tags = &tags
try
let &tags = eval(g:LookupFile_TagExpr)
let newpattern = '\c' . a:pattern
let tags = taglist(newpattern)
catch
echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE
return ""
finally
let &tags = _tags
endtry
" Show the matches for what is typed so far.
let files = map(tags, 'v:val["filename"]')
return files
endfunction
let g:LookupFile_LookupFunc = 'LookupFile_IgnoreCaseFunc'
"configuration for ConqueTeam
map <silent><leader>ct :ConqueTermSplit bash<cr>
"configuration for Pyclewn
map <silent><leader>db :Pyclewn<cr>
map <silent><leader>mk :Cmapkeys<cr>
"set ctags short keys
map <leader><C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q<cr>
"quickfix
map <silent><leader>cw :cw<cr>
map <silent><leader>cc :cc<cr>
map <silent><leader>cn :cn<cr>
map <silent><leader>cp :cp<cr>
map <silent><leader>col :col<cr>
map <silent><leader>cnew :cnew<cr>
"change to current dir
map <silent><leader>cd :cd %:h<cr>
"execute project related configuration
cd ~/code/
if filereadable("setting.vim")
source setting.vim
endif
"set guifont set guifont=Monaco\ 9 set lines=24 columns=80 winpos 381 114 "Toggle Menu and Toobar set guioptions -=m set guioptions -=T map <silent><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> "set tab number set guitablabel=%N/\ %t\ %M
衣带渐宽终不悔,为伊消得人憔悴
浙公网安备 33010602011771号