"*******************************************
"全局条件
"*******************************************
"设定操作系统
if has("win32") || has("win64") || has("win32unix")
let g:isWin = 1
else
let g:isWin = 0
endif
"*******************************************
"end全局条件
"*******************************************
"*******************************************
"常规
"*******************************************
"文件编码
"set encoding=utf-8
set fileencodings=ucs-bom,utf-8,gbk
set fileencoding=utf-8
"文件类型识别,添加相关类型的插件和缩进脚本
"filetype on
"filetype plugin on
filetype plugin indent on
"设置文件格式
set fileformat=unix
set fileformats=unix
"设置shell
if g:isWin == 0
set shell=bash
endif
"会话设置
set sessionoptions+=slash,unix
"关闭兼容模式
set nocompatible
"外部修改时自动读取
set autoread
"设置鼠标
set mouse=a
"设置历史
set history=400
"语法高亮
syntax enable
"查找结果高亮
set hlsearch
" 超过当前行长度的行会回绕
set wrap
"行号设置
set nu
"智能缩进,ts tabstop 转换tab键为空格来显示,主要用于屏幕显示和打印,
"如果页面全部用的tab,在tabstop=4和tabstop=8的地方页面显示的宽度是不同的
"sts softtabstop 在编辑的时候转换tab为空格的数量,需要和expandtab一起用
"et expandtab 在插入模式里插入tab时使用合适数量的空格代替
"sw shiftwidth 自动缩进每一步时使用的空白数目
set ai ts=4 sts=4 et sw=4
"设置色彩方案
colorscheme desert
"自动保存文件 autowrite
set aw
"搜索时忽略大小写
set ignorecase
"set ic
"增强命令行补全
set wildmenu
"加载系统特定的脚本
"source $VIMRUNTIME/vimrc_example.vim
if g:isWin == 1
source $VIMRUNTIME/mswin.vim
behave mswin
endif
set ambiwidth=double
set smarttab
set backspace=2
set textwidth=0
set mouse=a
"设置不备份
set nobackup
"设置打开文件的编码
"设置文件打开时的编码猜测列表
set fencs=utf-8,gb18030,utf-16,big5
"设置大于603版本时的帮助语言
if version >= 603
set helplang=cn
endif
"*******************************************
"end常规
"*******************************************
"*******************************
"设置Tlist
"*******************************
let Tlist_Show_One_File=1
" 如果 taglist 窗口是最后一个窗口,则退出 vim
let Tlist_Exit_OnlyWindow=1
let Tlist_Show_Menu=1
let Tlist_WinHeight=25
let Tlist_Use_Right_Window=1
"tasklist
"map T :TaskList<CR>
nmap <silent> <F4> :TlistToggle<CR>
"*******************************
" end设置Tlist
"*******************************
"*******************************
" 设置Winmanager
"*******************************
"WinManager
"let g:winManagerWindowLayout='NERDTree|TagList'
"let g:winManagerWindowLayout = 'NERDTree'
""设置winmanager的宽度,默认为25
"let g:winManagerWidth = 30
"nmap <F8> :WMToggle<cr>
"let g:AutoOpenWinManager = 1
"*******************************
" end 设置Winmanager
"*******************************
"*******************************
" 设置MiniBufExplorer
"*******************************
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
map! <Silent> <C-Tab> :bn<cr>
" miniBuf always show
"let g:miniBufExplorerMoreThanOne=0
"*******************************
" end 设置MiniBufExplorer
"*******************************
"*****************************
" 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
"*****************************
" end BufExplorer
"*****************************
"*****************************
" set Grep
"*****************************
let Grep_Path = 'D:/GnuWin32/bin/grep.exe'
let FGrep_Path = 'D:/GnuWin32/bin/fgrep.exe'
let EGrep_Path = 'D:/GnuWin32/bin/egrep.exe'
nnoremap <silent> <F3> :Grep<cr>
"*****************************
" end Grep
"*****************************
" *******************
" NERDTree set
" *******************
" set NERDTree curent dir
if g:isWin == 1
cd d:\
else
cd /home/zhaoyong
endif
let g:NERDTree_title = "[NERD Tree]"
let NERDTreeShowBookmarks=1 "一直显示书签
let NERDTreeChDirMode=2 "打开书签时,自动将Vim的pwd设为打开的目录,如果你的项目有tags文件,你会发现这个命令很有帮助
function! NERDTree_Start()
exe 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
nmap <silent> <F2> :NERDTreeToggle<CR>
" *******************
" end NERDTree set
" *******************
"nmap <F4> :NERDTree <CR>
" *******************
" php languange set "
" *******************
" set php document
set runtimepath+=d:\program\ Files\Vim\php_doc
if g:isWin == 1
map <C-J> :!php -l %<CR>
else
map <C-J> :!php -l %<CR>
endif
" *******************
" end php language set end
" *******************
" *******************
" python language set
" *******************
"
" set python document
let g:pyref_python = 'D:\program files\Vim\python-html'
" tags
set tags=d:\code\python\tags
" exec python
map <F6> :!python %
"Pydiction
let g:pydiction_location='D:\Program Files\Vim\vim73\ftplugin\pydiction\complete-dict'
"colorscheme my-molokai
"
" *******************
" end python language set
" *******************
" syntax highlight function
function! ToggleSyntax()
if exists("g:syntax_on")
syntax off
else
syntax enable
endif
endfunction
" 快速编辑vimrc文件的快捷键
map <silent> ee :e d:\program files\Vim\_vimrc<cr>
" 当vimrc已经保存后重载vimrc
autocmd! bufwritepost *_vimrc source d:\program\ files\Vim\_vimrc
autocmd! VimEnter * exec 'source' . " d:/program\ files/Vim/session.vim"
autocmd! VimLeave * <Leader>mbt
autocmd! VimLeave * :TlistClose<cr>
autocmd! VimLeave * :NERDTreeClose<cr>
autocmd! VimLeave * exec 'mksession!' . " d:/program\ files/Vim/session.vim"
" 使用CTRL+w 关闭当前缓存
"map <silent> <C-W> <C-k> d <cr> <C-j>
" 新建一个标签
map <silent> <C-N> :enew<cr>
" 启动时最大化窗口
au GUIEnter * simalt ~x
" 关闭当前的buf
map <silent> qq :bd<cr>
" 清理搜索高亮
map <silent> nhl /axkexiej<cr>
" 注释的映射键
let mapleader=","
map <silent> <leader>l :call NERDComment(0, "toggle")<cr>
map <silent> <leader>k :call NERDComment(0, "sexy")<cr>
" 括号自动补全
" map auto complete
"inoremap ( ()<esc>:let leavechar=")"<cr>i
inoremap [ []<esc>:let leavechar="]"<cr>i
inoremap { {<esc>o}<esc>:let leavechar="}"<cr>O
"inoremap { {}<esc>:let leavechar="}"<cr>i
"inoremap ' ''<esc>:let leavechar="'"<cr>i
"inoremap " ""<esc>:let leavechar='"'<cr>i
"au BufNewFile,BufRead *.\(vim\)\@! inoremap " ""<esc>:let leavechar='"'<cr>i
"au BufNewFile,BufRead *.\(txt\)\@! inoremap ' ''<esc>:let leavechar="'"<cr>i
"imap <m-l> <esc>:exec "normal f" . leavechar<cr>a
"imap <d-l> <esc>:exec "normal f" . leavechar<cr>
" 设置状态行
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v]\ [%p%%]\ [LEN=%L]
set laststatus=2