"整理了一下自己的vim配置文件,记录在此以备忘。
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 编码设置
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1,gb18030,gbk,cp936
if has("win32")
set fileencoding=chinese
else
set fileencoding=utf-8
endif
language messages zh_CN.utf-8
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 基础设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
set softtabstop=4
set shiftwidth=4
set tabstop=4
set bs=2
set autoread " read open files again when changed outside Vim
set autowrite " write a modified buffer on each :next , ...
set browsedir =current " which directory to use for the file browser
set wildmenu
set wildignore=*.bak,*.o,*.e,*~
set complete+=k " scan the files given with the 'dictionary' option
autocmd BufEnter * :lchdir %:p:h " Change the working directory to the directory containing the current file
filetype on
filetype plugin on
filetype indent on
syntax on
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 颜色设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
colorsc koehler
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 字体设置
set guifont=Consolas:h12:cANSI
set guifontwide=youyuan:h12
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 折叠设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set foldmethod=manual
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 缩进设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent
set smartindent
set cindent
set nowrap
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 界面设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set showtabline=2 "始终显示标签页
set guitablabel=%{tabpagenr()}.%t\ %m "每个tab上显示编号
set guioptions-=T "去掉工具条
set guioptions-=m "去掉菜单
set guioptions-=r "去掉右边的滚动条
set guioptions-=L
set statusline=%F%m%r%h%w\ [FMT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set laststatus=2
set scrolloff=3
set nu
set ruler
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 查找搜索设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set incsearch " use incremental search
set ignorecase smartcase
set hlsearch
set incsearch
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 将键盘上的F12健映射为执行当前文件
map <F12> :!%<CR>
" 使用Ctrl+Tab键来切换标签页
map <C-TAB> :tabn<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 快捷键设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" F2 - write file without confirmation
" F3 - call file explorer Ex
" F4 - show tag under curser in the preview window (tagfile must exist!)
" F5 - open quickfix error window
" F6 - close quickfix error window
" F7 - display previous error
" F8 - display next error
" S-Tab - Fast switching between buffers (see below)
" C-q - Leave the editor with Ctrl-q (see below)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <silent> <F2> :write<CR>
map <silent> <F3> :Explore<CR>
nmap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR>
map <silent> <F5> :copen<CR>
map <silent> <F6> :cclose<CR>
map <silent> <F7> :cp<CR>
map <silent> <F8> :cn<CR>
"
imap <silent> <F2> <Esc>:write<CR>
imap <silent> <F3> <Esc>:Explore<CR>
imap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR>
imap <silent> <F5> <Esc>:copen<CR>
imap <silent> <F6> <Esc>:cclose<CR>
imap <silent> <F7> <Esc>:cp<CR>
imap <silent> <F8> <Esc>:cn<CR>
map <silent> <s-tab> <Esc>:if &modifiable && !&readonly &&
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly &&
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
nmap <C-q> :wqa<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"taglist 设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <silent> <F11> <Esc><Esc>:Tlist<CR>
inoremap <silent> <F11> <Esc><Esc>:Tlist<CR>
let tlist_make_settings = 'make;m:makros;t:targets'
let tlist_qmake_settings = 'qmake;t:SystemVariables'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 特定文件类型设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufNewFile,BufRead *.mxml set filetype=mxml
au FileType python setlocal et sta sw=4 sts=4
au BufNewFile,BufRead *.pro set filetype=qmake
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""