""gVim启动窗口位置 大小 winpos 1366 768 set lines=40 columns=208 "设定文件编码 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 syntax on "配色风格 colorscheme desert "文本缩进设置 set tabstop=4 set shiftwidth=4 set autoindent set cindent set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s set nu "设置换行,自动换行" set wrap set linebreak "整词换行" "查找替换相关设置 set hlsearch "搜索结果高亮显示 set incsearch "查找单词,自动进行搜索 set gdefault "替换时,全部的行内匹配都被替代 "状态栏相关设置 set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] set laststatus=2 " 老是显示状态行 set ruler " 在编辑过程当中,在右下角显示光标位置的状态行 "若是没有下面这段就拷贝进来吧 虽然不知道干什么的 if &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dm endif "设定折叠方式 set foldmethod=indent "如下字符将被视为单词的一部分 (ASCII): set iskeyword+=33-47,58-64,91-96,123-128 "打开文件自动跳转到上次编辑的行 au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif "去掉兼容性" set nocompatible "Sets how many lines of history VIM har to remember set history=400 "文件在外部被修改则自动保存 set autoread " vim用户界面 " 括号自动匹配 inoremap ( ()<ESC>i inoremap ) <c-r>=ClosePair(')')<CR> inoremap { {}<ESC>i inoremap } <c-r>=ClosePair('}')<CR> inoremap [ []<ESC>i inoremap ] <c-r>=ClosePair(']')<CR> inoremap < <><ESC>i inoremap > <c-r>=ClosePair('>')<CR> function ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endf "jsbeautify插件配置 "Turn on WiLd menu set wildmenu "Always show current position set ruler "The commandbar is 2 high set cmdheight=2 "Show line number 显示行号 set nu "Set backspace set backspace=eol,start,indent "Bbackspace and cursor keys wrap to set whichwrap+=<,>,h,l "How many tenths of a second to blink set mat=2 "下面设置peaksea配色方案 if ! has("gui_running") set t_Co=256 endif " feel free to choose :set background=light for a different style set background=dark colors peaksea "编程相关的设置 filetype plugin on filetype indent on syn on set showmatch "括号匹配" set ai! "自动缩进 set autoindent "自动对齐 set smartindent "智能对齐 " 模仿MS Windows中的保存命令: Ctrl+S imap <C-s> <Esc>:wa<cr>i<Right> nmap <C-s> :wa<cr> "对NERD_commenter的设置 nmap <F3> :NERDTree <CR> "NERDTree Settings{ let NERDTreeWinPos ="left" "将NERDTree的窗口设置在gvim窗口的左边 let NERDTreeShowBookmarks=1 "当打开NERDTree窗口时,自动显示Bookmarks "} "粘贴不变形 set paste "netrw 文件浏览器 :e <PATH> let g:netrw_winsize = 20 "浏览器宽度 "tags插件配置" set tags=/home/twins/tags "下面是对taglist插件的相关配置" let Tlist_Show_One_File=1 let Tlist_Exit_OnlyWindow=1 let Tlist_Use_Right_Window=1 "下面是对windowsManager插件的相关配置" let g:winManagerWindowLayout= 'FileExplorer|TagList' let g:winManagerWidth = 20 let g:defaultExplorer = 0 nmap <C-w><C-b> :BottomExplorerWindow<cr> nmap <C-w><C-f> :FirstExplorerWindow<cr> nmap wm:WMToggle<cr> "miniBuffer插件 let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 "authorinfo插件的配置 let g:vimrc_author='twins' let g:vimrc_email='jhsrcmh1992@gmail.com' let g:vimrc_homepage='http://www.hit.edu.cn' nmap <F4> :AuthorInfoDetect<cr> " ======= 编译 && 运行 ======= " " 编译源文件 func! CompileCode() exec "w" if &filetype == "c" exec "!gcc -Wall -std=c99 %<.c -o %<" elseif &filetype == "cpp" exec "!g++ -Wall -std=c++98 %<.cpp -o %<" elseif &filetype == "java" exec "!javac %<.java" elseif &filetype == "haskell" exec "!ghc --make %<.hs -o %<" elseif &filetype == "lua" exec "!lua %<.lua" elseif &filetype == "perl" exec "!perl %<.pl" elseif &filetype == "python" exec "!python %<.py" elseif &filetype == "ruby" exec "!ruby %<.rb" endif endfunc " 运行可执行文件 func! RunCode() exec "w" if &filetype == "c" || &filetype == "cpp" || &filetype == "haskell" exec "! %<.exe" elseif &filetype == "java"C exec "!java %<" elseif &filetype == "lua" exec "!lua %<.lua" elseif &filetype == "perl" exec "!perl %<.pl" elseif &filetype == "python" exec "!python %<.py" elseif &filetype == "ruby" exec "!ruby %<.rb" endif endfunc " Ctrl + C 一键保存、编译 map <c-m><ESC> :call CompileCode()<cr> imap <c-m><ESC>:call CompileCode()<cr> vmap <c-m><ESC>:call CompileCode()<cr> " Ctrl + R 一键保存、运行 map <C-r><ESC> :call RunCode()<cr> imap <C-r><ESC>:call RunCode()<cr> vmap <C-r><ESC>:call RunCode()<cr> "对.vimrc配置文件的修改当即生效 autocmd! bufwritepost _vimrc source %
这个即是个人vim配置文件了。html
vim的可配置性很是强,它给人的也是一种个性化的享受。java
配置过程当中,有一个点出现问题,map过程当中,多了一个:回车不能用了。。粗心的孩子或许能找到问题所在。python
还有一个很是强大的参考:c++
https://github.com/feelinglucky/vimrc/blob/master/_vimrcgit
听说史上最牛的vim配置文件:http://amix.dk/vim/vimrc.htmlgithub