vimrc 配置 史上最牛

http://amix.dk/vim/vimrc.html  我了个去 真强大


另附一个vimrc
" vim:shiftwidth=2:tabstop=8:expandtab

if has('autocmd')
  " Remove ALL autocommands for the current group
  au!

  " Mark .asm files MASM-type assembly
  au BufNewFile,BufReadPre *.asm let b:asmsyntax='masm'
endif

if has('gui_running')
  let do_syntax_sel_menu=1
endif

if has('gui_running') && $LANG !~ '\.'
  set encoding=utf-8
endif

set nocompatible
source $VIMRUNTIME/vimrc_example.vim

set autoindent
set nobackup
set showmatch
set formatoptions+=mM
set fileencodings=ucs-bom,utf-8,gbk
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
if has('mouse')
  set mouse=a
endif
if has('multi_byte') && v:version > 601
  if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
    set ambiwidth=double
  endif
endif

" Key mappings to ease browsing long lines
noremap  <C-J>       gj
noremap  <C-K>       gk
noremap  <Down>      gj
noremap  <Up>        gk
inoremap <Down> <C-O>gj
inoremap <Up>   <C-O>gk

" Key mappings for quick arithmetic inside Vim
nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$
vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$
nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$
vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap

" Key mapping to stop the search highlight
nmap <silent> <F2>      :nohlsearch<CR>
imap <silent> <F2> <C-O>:nohlsearch<CR>

" Key mapping for the taglist.vim plugin
nmap <F9>      :Tlist<CR>
imap <F9> <C-O>:Tlist<CR>

" Key mappings for the quickfix commands
nmap <F11> :cn<CR>
nmap <F12> :cp<CR>

" Non-GUI setting
if !has('gui_running')
  " Do not increase the windows width in the taglist.vim plugin
  if has('eval')
    let Tlist_Inc_Winwidth=0
  endif

  " Set text-mode menu
  if has('wildmenu')
    set wildmenu
    set cpoptions-=<
    set wildcharm=<C-Z>
    nmap <F10>      :emenu <C-Z>
    imap <F10> <C-O>:emenu <C-Z>
  endif
endif

if has('autocmd')
  function! SetFileEncodings(encodings)
    let b:my_fileencodings_bak=&fileencodings
    let &fileencodings=a:encodings
  endfunction

  function! RestoreFileEncodings()
    let &fileencodings=b:my_fileencodings_bak
    unlet b:my_fileencodings_bak
  endfunction

  function! CheckFileEncoding()
    if &modified && &fileencoding != ''
      exec 'e! ++enc=' . &fileencoding
    endif
  endfunction

  function! ConvertHtmlEncoding(encoding)
    if a:encoding ==? 'gb2312'
      return 'gbk'              " GB2312 imprecisely means GBK in HTML
    elseif a:encoding ==? 'iso-8859-1'
      return 'latin1'           " The canonical encoding name in Vim
    elseif a:encoding ==? 'utf8'
      return 'utf-8'            " Other encoding aliases should follow here
    else
      return a:encoding
    endif
  endfunction

  function! DetectHtmlEncoding()
    if &filetype != 'html'
      return
    endif
    normal m`
    normal gg
    if search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html; charset=[-A-Za-z0-9_]\+">') != 0
      let reg_bak=@"
      normal y$
      let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')
      let charset=ConvertHtmlEncoding(charset)
      normal ``
      let @"=reg_bak
      if &fileencodings == ''
        let auto_encodings=',' . &encoding . ','
      else
        let auto_encodings=',' . &fileencodings . ','
      endif
      if charset !=? &fileencoding &&
         \(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding == '')
        silent! exec 'e ++enc=' . charset
      endif
    else
      normal ``
    endif
  endfunction

  function! GnuIndent()
    setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
    setlocal shiftwidth=2
    setlocal tabstop=8
  endfunction

  function! RemoveTrailingSpace()
    if $VIM_HATE_SPACE_ERRORS != '0' &&
          \(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')
      normal m`
      silent! :%s/\s\+$//e
      normal ``
    endif
  endfunction

  " Highlight space errors in C/C++ source files (Vim tip #935)
  if $VIM_HATE_SPACE_ERRORS != '0'
    let c_space_errors=1
  endif

  " Use Canadian spelling convention in engspchk (Vim script #195)
  let spchkdialect='can'

  " Show syntax highlighting attributes of character under cursor (Vim
  " script #383)
  map <Leader>a :call SyntaxAttr()<CR>

  " Automatically find scripts in the autoload directory
  au FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'

  " File type related autosetting
  au FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4
  au FileType diff  setlocal shiftwidth=4 tabstop=4
  au FileType html  setlocal autoindent indentexpr=
  au FileType changelog setlocal textwidth=76

  " Text file encoding autodetection
  au BufReadPre  *.gb               call SetFileEncodings('gbk')
  au BufReadPre  *.big5             call SetFileEncodings('big5')
  au BufReadPre  *.nfo              call SetFileEncodings('cp437')
  au BufReadPost *.gb,*.big5,*.nfo  call RestoreFileEncodings()
  au BufWinEnter *.txt              call CheckFileEncoding()

  " Detect charset encoding in an HTML file
  au BufReadPost *.htm* nested      call DetectHtmlEncoding()

  " Recognize standard C++ headers
  au BufEnter /usr/include/c++/*    setf cpp
  au BufEnter /usr/include/g++-3/*  setf cpp

  " Setting for files following the GNU coding standard
  au BufEnter /usr/*                call GnuIndent()

  " Remove trailing spaces for C/C++ and Vim files
  au BufWritePre *                  call RemoveTrailingSpace()
endif

转载于:https://www.cnblogs.com/zhihaowang/archive/2011/01/07/10128591.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
windows下的Gvim7.2的配置文件 增加了"文件浏览"和Taglist等一系列插件. 插件也在压缩包内 "本配置文件包括如下内容: "设定窗口打开位置 winpos 300 60 "设定窗口起始大小 set lines=50 columns=118 " 设定默认解码及解决Vim终端模式中文乱码---顺序不要写错! let &termencoding=&encoding set encoding=utf-8 set langmenu=zh_CN.UTF-8 language message zh_CN.UTF-8 set fenc=utf-8 set fencs=usc-bom,utf-8,gb18030,gbk,gb2312,big5,cp936,euc-jp,euc-kr,latin1, set nocompatible source $vimruntime/vimrc_example.vim source $vimruntime/mswin.vim behave mswin "切换提示语言(解决调试窗口提示乱码) 设置帮助语言 文件中需要记录的行数 在处理未保存或只读文件的时候,弹出确认 与windows共享剪贴板 侦测文件类型 带有如下符号的单词不要被换行分割 语法高亮 高亮字符,让其不受100列限制 状态行颜色 把gui的工具栏去掉 把gui的菜单去掉 文件设置 不要备份文件(根据自己需要取舍) 不要生成swap文件,当buffer被丢弃的时候隐藏它 字符间插入的像素行数目 增强模式中的命令行自动完成操作 在状态行上显示光标所在位置的行号和列号 命令行(在状态行下)的高度 允许backspace和光标键跨越行边界 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位) 启动的时候不显示那个援助索马里儿童的提示 在被分割的窗口间显示空白,便于阅读 打开文件时光标自动到上次退出该文件时的光标所在位置 搜索和匹配 显示状态行 Lookupfile 相关设置 继承前一行的缩进方式,特别适用于多行注释 为C程序提供自动缩进 TAB键宽度 统一缩进为4 换行 在行和段开始处使用制表符 可以用切换到上下左右的窗口中去 CTags的设定 Autocommands 自动补全 显示行号 只在下列文件类型被侦测到的时候显示行号,普通文本文件不显示 设置程序的运行和调试 快捷键F5和Ctrl-F5 更详细资料见文件.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值