我的vim配置文件
因?yàn)椴粫?huì)用github,所以放在這里,心情不好就來(lái)看看。
都是非常基礎(chǔ)的功能,寫點(diǎn)小程序用。
windows版
syntax on set backspace=indent,eol,start set nu si ci ai mouse=a sw=4 sts=4 ts=4 set hlsearch incsearch colorscheme desert set guifont=Consolas:h14 set report=0 showmatch cursorline set guioptions-=m set guioptions-=T nmap<F3> : vs %<.in <CR> nmap<F4> : ! %< < %<.in <CR> nmap<F5> : ! java %< < %<.in <CR> nmap<F6> : vs %<.out <CR> "nmap<F9> : !g++ % -o %< <CR> "nmap<F10> : ! %< <CR>nmap w, :vertical resize -5<CR> nmap w. :vertical resize +5<CR>map <F9> :call InitCompile()<CR> func! InitCompile()exec "w"if &filetype == 'c'exec "!g++ -std=c++11 -static -m32 % -o %<"elseif &filetype == 'cpp'exec "!g++ -std=c++11 % -o %<"elseif &filetype == 'java' exec "!javac %" endif endfuncmap <F10> :call CompileRunGcc()<CR> func! CompileRunGcc()if &filetype == 'c'exec "! %<"elseif &filetype == 'cpp'exec "! %<"elseif &filetype == 'java' exec "! java %<"endif endfunc" 語(yǔ)言設(shè)置 "gvim內(nèi)部編碼 set encoding=utf-8 "設(shè)置終端編碼為gvim內(nèi)部編碼encoding let &termencoding=&encoding "當(dāng)前編輯的文件編碼 set fileencoding=utf-8 "gvim打開(kāi)支持編碼的文件 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set langmenu=zh_CN.UTF-8 "解決consle輸出亂碼 language messages zh_cn.utf-8 "菜單欄中文 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim"樹(shù)形目錄開(kāi)關(guān) map <F12> :NERDTreeMirror<CR> map <F12> :NERDTreeToggle<CR> let NERDTreeSortOrder=['//$','/.cpp$','/.c$', '/.h$', '*']"復(fù)制粘貼控制 "vmap <C-c> "+yi nmap<C-A> ggvG vmap<C-C> "*y vmap <C-x> "+c vmap <C-v> c<ESC>"+p imap <C-v> <ESC>"+pa set cindent set scrolloff=3 "按<F2>自動(dòng)生成代碼設(shè)置 if !exists("*SetTitlea") map <F2> :call SetTitlea()<CR> func SetTitlea() let l = 0 let l = l + 1 | call setline(l,'#include <cstdio>') let l = l + 1 | call setline(l,'#include <cstring>') let l = l + 1 | call setline(l,'#include <iostream>') let l = l + 1 | call setline(l,'using namespace std;') let l = l + 1 | call setline(l,'int main()') let l = l + 1 | call setline(l,'{') let l = l + 1 | call setline(l,' return 0;') let l = l + 1 | call setline(l,'}') endfunc endiflinux版
if filereadable(expand("~/.vimrc.bundles"))source ~/.vimrc.bundles endifset backspace=indent,eol,start set nu ai ci si sts=4 ts=4 sw=4 mouse=anmap<F3> : vs %<.in <CR> nmap<F4> :call XX() <CR> func! XX()exec "w"exec "!time ./%< < %<.in" endfunc nmap<F5> : !time java %< < %<.in <CR> nmap<F6> : vs %<.out <CR>" nmap<F7> : call RJ() <CR> func! RJ()exec "w"exec "!javac %" endfuncnmap w, :vertical resize -5<CR> nmap w. :vertical resize +5<CR>"nmap<F9> : make %< <CR> map <F9> :call InitCompile()<CR> func! InitCompile()exec "w"if &filetype == 'c'exec "!gcc % -o %<"elseif &filetype == 'cpp'exec "!g++ -std=c++11 % -o %<"elseif &filetype == 'java' exec "!javac %" elseif &filetype == 'sh':!./%endif endfunc"nmap<F10> : !./%< <CR> map <F10> :call CompileRunGcc()<CR> func! CompileRunGcc()exec "w"if &filetype == 'c'exec "!time ./%<"elseif &filetype == 'cpp'exec "!time ./%<"elseif &filetype == 'java' exec "!time java %<"elseif &filetype == 'sh':!./%endif endfunc"filetype plugin indent on "set completeopt=longest,menu "代碼補(bǔ)全 ":cd /home/kw " 默認(rèn)路徑" 樹(shù)形目錄 nmap <F12> :NERDTreeToggle<cr>"設(shè)置Tab鍵跟行尾符顯示出來(lái) "set list lcs=tab:>-,trail:- " "let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'syntax on syntax enable set mouse=a set mousehide set backup "undo? set number set ruler colorscheme desert set backspace=2 " set autoindent "自動(dòng)縮進(jìn) " set smartindent "智能縮進(jìn)set cindent "C系列縮進(jìn)set softtabstop=4 "縮進(jìn)長(zhǎng)度set shiftwidth=4 "縮進(jìn)長(zhǎng)度set tabstop=4 "tab鍵長(zhǎng)度 " set expandtab "tab設(shè)為空格set softtabstop=4 "縮進(jìn)長(zhǎng)度vnoremap $1 <esc>`>a)<esc>`<i(<esc> vnoremap $2 <esc>`>a]<esc>`<i[<esc> vnoremap $3 <esc>`>a}<esc>`<i{<esc> vnoremap $$ <esc>`>a"<esc>`<i"<esc> vnoremap $q <esc>`>a'<esc>`<i'<esc> vnoremap $e <esc>`>a"<esc>`<i"<esc> " 括號(hào)自動(dòng)生成"""""""""""""""""""""""" ""實(shí)用設(shè)置 """""""""""""""""""""""" "set transparency=10 "透明度 "set lines=55 "窗口多長(zhǎng),下為多寬 "set columns=100 set scrolloff=3 " 光標(biāo)移動(dòng)到buffer的頂部和底部時(shí)保持3行距離" 語(yǔ)言設(shè)置 " "gvim內(nèi)部編碼 set encoding=utf-8 "設(shè)置終端編碼為gvim內(nèi)部編碼encoding let &termencoding=&encoding "當(dāng)前編輯的文件編碼 set fileencoding=utf-8 "gvim打開(kāi)支持編碼的文件 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set langmenu=zh_CN.UTF-8 "解決consle輸出亂碼 "language messages zh_cn.utf-8 "菜單欄中文 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vimautocmd BufWritePost $MYVIMRC source $MYVIMRC " 讓配置變更立即生效" colorscheme solarized "配色沙漠 還有: torte, solarized, molokai, phd, ron, evening 等經(jīng)典配色 " set guifont = Source_Code_Pro:h15 " 設(shè)置字體為 字體:大小 "set guifont=Menlo:h15 "字體和大小 set laststatus=2 " 命令行(在狀態(tài)行下)的高度,默認(rèn)為1,這里是2 set wildmenu " 使回格鍵(backspace)正常處理indent, eol, start等 let Tlist_Use_Right_Window = 1 "在右側(cè)窗口中顯示taglist窗口set showmatch "自動(dòng)匹配 set wildmenu " vim 自身命令行模式智能補(bǔ)全 set nobackup set noswapfile "禁止生成臨時(shí)文件nmap <Leader>Q :qa!<CR> " 依次遍歷子窗口 nnoremap nw <C-W><C-W> " 跳轉(zhuǎn)至右方的窗口 nnoremap <Leader>lw <C-W>l " 跳轉(zhuǎn)至左方的窗口"復(fù)制粘貼控制 vmap <C-c> "+y vmap <C-x> "+c vmap <C-v> c<ESC>"+p imap <C-v> <ESC>"+pa nmap <C-A> ggVG"按<F2>自動(dòng)生成代碼設(shè)置 if !exists("*SetTitlea") map <F2> :call SetTitlea()<CR> func SetTitlea() if &filetype == 'c' || &filetype == 'cpp'let l = 0let l = 1 | call setline(1,'// Last modify : '.strftime('%c'))let l = l + 1 | call setline(l,'#include <cstdio>')let l = l + 1 | call setline(l,'#include <cstring>')let l = l + 1 | call setline(l,'#include <iostream>')let l = l + 1 | call setline(l,'using namespace std;')let l = l + 1 | call setline(l,'}')let l = l + 1 | call setline(l,'')let l = l + 1 | call setline(l,'int main()')let l = l + 1 | call setline(l,'{')let l = l + 1 | call setline(l,'')let l = l + 1 | call setline(l,' return 0;')let l = l + 1 | call setline(l,'}') elseif &filetype == 'java'let l = 0let l = 1 | call setline(1,'// Last modify : '.strftime('%c'))let l = l + 1 | call setline(l,'public class '.expand("%<").expand(" {"))let l = l + 1 | call setline(l,' public static void main(String[] args) {')let l = l + 1 | call setline(l,' }')let l = l + 1 | call setline(l,'}') endifendfunc endif"時(shí)間戳 map <F1> :call SaveCompileRun()<CR> func! SaveCompileRun()let l = 1 | call setline(1,'// Last modify : '.strftime('%c'))exec "w"endfunc" 設(shè)置當(dāng)文件被改動(dòng)時(shí)自動(dòng)載入 " set autoread" set backspace=” (Vi compatible)總結(jié)
- 上一篇: WIN10+MinGW中文输出乱码的解决
- 下一篇: frp端口映射服务器搭建