首页 > 代码库 > vimrc的完全版本
vimrc的完全版本
" -------------------- Copyright Header Begin ---------------------------------" Description : Facilitates vim settings " Version : 2.0.1" Author : RollStone,jealdean@outlook.com" Copyright : RollStone (2007-2014)." LastChanged : 2014-10-14 00:45:09" -------------------- Copyright Header End -----------------------------------" Overview for maintainers :" The file is divided into following sections. You may add yours or update these" if/when you choose to enhance this setting file."" + General Settings" + Tips(just need to how use these functions)" + Autocmds" + Plugins " + Mappings"{{{ ---------------- General Settings Begin ---------------------------------"MC: My Contaction"abbr mc RollStone,jealdean@outlook.com"Leaderlet g:mapleader=‘,‘"Just more like vim,less viset nocompatible"backupset nobackup"colorschemeset t_Co=256colorscheme peakseaif &diff colorscheme peakseaendif"dirsset autochdirset autoreadset autowrite"completeset complete+=k"set wildmenuset completeopt=longest,menuset formatoptions+=mMset cinoptions=:0,l1,t0,g0set nosmdset nosc"encodingsset fileencodings=utf-8,gbk,gb18030,chinese"indentset autoindentset smartindentset noexpandtabset tabstop=4set shiftwidth=4"searchset incsearchset hlsearchset ignorecase"statuslineset laststatus=2"tabulationset rulerset numberset list lcs=tab:\¦\ "wrapset nowrapset nowrapscan"othersset backspace=indent,eol,startset wildignore=*.bak,*.o,*.e,*~set browsedir=currentset sessionoptions-=curdirset ttimeoutlen=100set vb t_vb="some common gatessyntax onfiletype plugin indent on"}}} ---------------- General Settings End -----------------------------------" Tips {{{1"notice: n just be in normal mode"tip1. match ()/{}/[]"n: % (first chang into normal mode,and press shift + 5)"tip2. find the manual content"n: K (first chang into normal mode,and press shift + K)"tip3. return prev window after ‘gf‘"n:<ctrl-o>"tip4. check what options"c: set [all]" Autocmds {{{1if has("autocmd") "when modifies vimrc or .vimrc reload it au BufWritePost [ _.]vimrc source ~/.vimrc "auto chdir to curdir au BufEnter * :lchdir %:p:h "change to the lastest cursor position au BufReadPost * if line("‘\"") > 0 && line("‘\"") <= line("$") | exe "normal! g`\"" | endif endif " has (autocmd)"" Plugins {{{1"c.vim(c-support)let g:C_MapLeader=‘;‘"powerlinelet g:Powerline_cache_dir=simplify(expand(‘%:p:h‘))let g:Powerline_cache_enabled=0"let g:Powerline_dividers_override = [‘>>‘, ‘>‘, ‘<<‘, ‘<‘]"overrid mode_name"let g:Powerline_mode_n=‘n‘let g:Powerline_mode_i=‘i‘let g:Powerline_mode_v=‘V‘let g:Powerline_mode_R=‘R‘let g:Powerline_stl_path_style=‘full‘"taglistlet Tlist_Auto_Open=0let Tlist_WinWidth=38let Tlist_Exit_OnlyWindow=1let Tlist_Use_Right_Window=0let Tlist_Close_On_Select=1let Tlist_File_Fold_Auto_Close = 0let Tlist_GainFocus_On_ToggleOpen=1let Tlist_Display_Prototype = 1"windowmanagerlet g:winManagerWidth=g:Tlist_WinWidthlet g:winManagerWindowLayout=‘TagList|FileExplorer‘let g:wiw=60nmap wm :WMToggle<cr>""}}} ----------------- Plugins End --------------------------------------------"---------------- Mappings Begin -----------------------------------------{{{1 "F1 - overrule Linux F1map <silent> <F1> <esc>:exec "help ".expand("<cword>")<cr>"F2 - call file explorer Exmap <silent> <F2> :Explorerimap <silent> <F2> <esc>:Explorer"F3 - remove trail white-spacemap <silent> <F3> :%s/[ \t\r]\+$//g<cr>imap <silent> <F3> <esc>:%s/[ \t\r]\+$//g<cr>"F5-F8 :quickfix :open/close error windows,display prev/next errormap <silent> <F5> :copen<cr>map <silent> <F6> :cclose<cr>map <silent> <F7> :cp<cr>map <silent> <F8> :cn<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>"autocomplete parenthesis, brackets and bracesinoremap ( ()<Left>inoremap [ []<Left>inoremap { {}<Left>vnoremap ( s()<Esc>P<Right>%vnoremap [ s[]<Esc>P<Right>%vnoremap { s{}<Esc>P<Right>%inoremap , , "Open includes files in a new split windowset path=.,include,../include,/usr/include,/usr/local/include"nmap gf <c-w><c-f>"{{User defines functions and its‘ map"Format C/CPP codes,and return current linefunction! UDFormatCppCode() silent exec "ks| normal gg=G|‘s"endfuncnmap fmt :call UDFormatCppCode()<cr>imap fmt <esc>:call UDFormatCppCode()<cr>oau BufWritePre,FileWritePre *.c,*.cpp,*.h,*.hpp,*.java :call UDFormatCppCode()"Author Info Adderfunction! UDAuthorInfoAdd() let aid_author=‘RollStone‘ let aid_email=‘jealdean@outlook.com‘ let fts=expand(‘%:p:e‘) if fts == ‘sh‘ || fts == ‘pl‘ "script file call setline(1,[‘#=============================================================‘ \,‘# Filename: ‘.expand(‘%:t‘) \,‘# Brief: TODO ‘ \,‘# Author: ‘.aid_author \,‘# Email: ‘.aid_email \,‘# LastChange: ‘.strftime(‘%F %T‘) \,‘# Revision: ‘ \,‘#=============================================================‘]) "add FileHeader first line let line=getline(0) if line !~ ‘^\#\!\/bin\/.*$‘ let lstr=expand(‘%:p:e‘) if lstr == ‘sh‘ let newline= ‘#!/bin/bash‘ elseif lstr == ‘pl‘ let newline= ‘#!/bin/perl‘ endif call append(0,newline) endif else "elseif fts == ‘c‘ || fts ==‘h‘ || fts =~ ‘\*pp‘ || fts == ‘java‘ "program files let line=getline(0) if line !~ ‘^\/\*.*$‘ call append(0,[‘/*‘ \,‘*==============================================================================‘ \,‘* Filename: ‘.expand(‘%:t‘) \,‘* Brief: TODO ‘ \,‘* Author: ‘.aid_author \,‘* Email: ‘.aid_email \,‘* LastChange: ‘.strftime(‘%F %T‘) \,‘* Revision: ‘ \,‘*==============================================================================‘ \,‘*/‘]) endif endif echohl WarningMsg | echo "Success to add FileHeader" | echohl Noneendfunc"Author Info Detectfunction! UDAuthorInfoDetect() let n=1 let updated=0 while n<20 let line=getline(n) if line =~ ‘^.*ile.ame.*:*.*$‘ let newline=substitute(line,‘:.*$‘,‘: ‘.expand(‘%:t‘),‘g‘) call setline(n,newline) let updated = 1 elseif line =~ ‘^.*hange.*:\S*.*$‘ let newline=substitute(line,‘:.*$‘,‘: ‘.strftime("%Y-%m-%d %H:%M:%S"),‘g‘) call setline(n,newline) let updated = 1 endif let n+=1 endwhile " if updated == 1 echohl WarningMsg | echo "Success to update FileHeader." | echohl None else call UDAuthorInfoAdd() endifendfuncnmap udaid :call UDAuthorInfoAdd()<cr>imap udaid <esc>:call UDAuthorInfoAdd()<cr>$a"update last modified changesau BufNewFile *.sh,*.pl,*.txt,*.java,*.go :call UDAuthorInfoAdd()au BufWrite,FileWritePre,FileAppendPre *vimrc,*.sh,*.pl,*.h,*.c,*.*pp :call UDAuthorInfoDetect()
vimrc的完全版本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。