博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vim配置文件
阅读量:6695 次
发布时间:2019-06-25

本文共 6297 字,大约阅读时间需要 20 分钟。

hot3.png

为了方便和编辑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""""""""""""""""""""""""""""""""""""""""

转载于:https://my.oschina.net/fufangchun/blog/95524

你可能感兴趣的文章
Android如何实现超级棒的沉浸式体验
查看>>
UWP开发入门(十七)——判断设备类型及响应VirtualKey
查看>>
PHP-Casbin v0.2 发布,轻量级开源访问控制框架
查看>>
JavaScript test framework : Mocha
查看>>
Bootstrap级联下拉菜单,你肯定用得到
查看>>
还是写 Android 爽啊!
查看>>
Vue-router的基本用法
查看>>
WPF-利用Blend写的平面控制闸门开关动画
查看>>
设计模式---外观模式(门面模式)(DesignPattern_Facade)
查看>>
java B2B2C电子商务平台分析之七-Spring Cloud Config
查看>>
Gradle 多渠道打包
查看>>
换芯后的 Edge 浏览器 UI 首曝光,还是熟悉的味道?
查看>>
Spring API 开发简单示例及技巧
查看>>
Confluence 6 修改 Home 目录的位置
查看>>
4Fun获千万元级 Pre-A 轮融资,要做印度的快手
查看>>
你需要知道的conda(原创,转载注明出处)
查看>>
@Controller和@RestController的区别?
查看>>
EasyTabPager
查看>>
Java根据两点经纬度计算距离
查看>>
elastic search head 基本用法
查看>>