为了方便和编辑linux中的文件,在此给出个人的vim配置文件,只需覆盖到个人家目录下【~/.vimrc】,即可。
另,确保在vi时,等同于vim
alias vi=“vim”
"create by perofu
"Email:perofu.com@gmail.com " "1.[,/] :note a line "2.ctrl+a :select all lines,windows [ctrl+a] "3.ctrl+b :paste,windows [ctrl+v] "4.ctrl+x :cut,windows [ctrl+x] "5.ctrl+c :copy,windows [ctrl+c] """""""""""""""""""""""""""""context""""""""""""""""""""""""""""" " if has("multi_byte") " When 'fileencodings' starts with 'ucs-bom', don't do this manually "set bomb set fileencodings=ucs-bom,chinese,taiwan,japan,korea,utf-8,latin1 " CJK environment detection and corresponding setting if v:lang =~ "^zh_CN" " Simplified Chinese, on Unix euc-cn, on MS-Windows cp936 set encoding=chinese set termencoding=chinese if &fileencoding == '' set fileencoding=chinese endif elseif v:lang =~ "^zh_TW" " Traditional Chinese, on Unix euc-tw, on MS-Windows cp950 set encoding=taiwan set termencoding=taiwan if &fileencoding == '' set fileencoding=taiwan endif elseif v:lang =~ "^ja_JP" " Japanese, on Unix euc-jp, on MS-Windows cp932 set encoding=japan set termencoding=japan if &fileencoding == '' set fileencoding=japan endif elseif v:lang =~ "^ko" " Korean on Unix euc-kr, on MS-Windows cp949 set encoding=korea set termencoding=korea if &fileencoding == '' set fileencoding=korea endif endif " Detect UTF-8 locale, and override CJK setting if needed if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set encoding=utf-8 endif else echoerr 'Sorry, this version of (g)Vim was not compiled with "multi_byte"' endif " 设定默认解码 set encoding=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 set fileencodings=utf-8,ucs-bom,chinese set helplang=cn set nocompatible set linebreak highlight LeaderTab guifg=#666666 syntax on set history=100 set linespace=0 set wildmenu set backspace=2 set whichwrap+=<,>,h,l set confirm set clipboard+=unnamed filetype on filetype plugin on set autoread filetype indent on set iskeyword+=_,$,@,%,#,- :highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white :match OverLength '\%101v.*' set scrolloff=3 set novisualbell set fillchars=vert:\ ,stl:\ ,stlnc:\ set showmatch set matchtime=5 set formatoptions=tcrqn set noincsearch set ignorecase set nohlsearch set hlsearch set magic set hidden set incsearch set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ imap <f4> <C-r>=GetDateStamp()<cr> filetype plugin indent on "打开文件类型检测 set completeopt=longest,menu "关掉智能补全时的预览窗口 imap <M-/> <C-X><C-O> autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType php set omnifunc=phpcomplete#CompletePHP autocmd FileType c set omnifunc=ccomplete#Complete autocmd FileType java set omnifunc=javacomplete#Complete """"""""""""""""""""""""""""visual"""""""""""""""""""""""""""""""" set noerrorbells set novisualbell set t_vb= """"""""""""""""""""""""""""end visual"""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""mouse"""""""""""""""""""""""""""""""""" set mouse=a set selection=exclusive set selectmode=mouse,key """""""""""""""""""""""""""""""end mouse"""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""indentation"""""""""""""""""""""""""""""""""" set tabstop=4 set softtabstop=4 set shiftwidth=4 set autoindent set cindent if &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dm endif set smartindent set noexpandtab set nowrap set smarttab """""""""""""""""""""""""""""""end indentation"""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""line number"""""""""""""""""""""""""""""""" if has("autocmd") autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number autocmd FileType xml,html vmap <C-o> <ESC>'<i<!--<ESC>o<ESC>'>o--> autocmd FileType java,c,cpp,cs vmap <C-o> <ESC>'<o/*<ESC>'>o*/ autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100 autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif endif " has("autocmd") """""""""""""""""""""""""""""""end line number"""""""""""""""""""""""""""""""" " 总是显示状态行 set laststatus=2 set statusline=%F\ %h%1*%m%r%w%0*[%{strlen(&filetype)?&filetype:'none'},%{&encoding},%{&fileformat}]%=%-14.(%l,%c%V%)\ %<%p%%\ \ \ [%L]\ \ \ %{strftime('%Y-%m-%d\ -\ %H:%M\ %A')} set ruler set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%) highlight StatusLine guifg=SlateBlue guibg=Yellow highlight StatusLineNC guifg=Gray guibg=White """""""""""""""""""""""""""""end status"""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""load tags""""""""""""""""""""""""""""""""""" if exists("tags") set tags=./tags endif let Tlist_Show_One_File=0 let Tlist_File_Fold_Auto_Close=1 let Tlist_Exit_OnlyWindow=1 let Tlist_Use_SingleClick=1 let Tlist_GainFocus_On_ToggleOpen=1 let Tlist_Process_File_Always=1 """"""""""""""""""""""""""""""""end tags""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""backup"""""""""""""""""""""""""""""""""""" "set nobackup "setlocal noswapfile "set bufhidden=hide """"""""""""""""""""""""""""""end backup"""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""keyboard""""""""""""""""""""""""""""""""" vmap <C-c> "yy nmap <C-c> "yy vmap <C-x> "yd nmap <C-b> "yp vmap <C-b> "yp nmap <C-a> ggvG$ let mapleader = "," let g:mapleader = "," "noremap <space> : noremap <leader>/ ^i# noremap <leader>t :TlistToggle<CR> noremap <leader>n :tabnext<CR> noremap <leader>b :tabprev<CR> noremap <leader>o :browse tabnew<CR> """"""""""""""""""""""""""""""end keyboard""""""""""""""""""""""""""""""""" "function! AutoClose() :inoremap ( ()<ESC>i :inoremap " ""<ESC>i :inoremap ' ''<ESC>i :inoremap { {}<ESC>i :inoremap [ []<ESC>i :inoremap ) <c-r>=ClosePair(')')<CR> :inoremap } <c-r>=ClosePair('}')<CR> :inoremap ] <c-r>=ClosePair(']')<CR> "endf function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endf """"""""""""""""""""""""""""""end contex""""""""""""""""""""""""""""""""""""""""