vim配置

1 效果图

 2 支持的功能

  • 函数跳转
  • 侧边栏函数显示
  • 代码补全
  • 鼠标操作
  • 复制粘贴
  • 按键自定义映射

3 使用的插件

  • ctags
  • taglist
  • cscope

4 配置文件

  1 if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
  2    set fileencodings=ucs-bom,utf-8,latin1
  3 endif
  4 
  5 set nocompatible    " Use Vim defaults (much better!)
  6 set bs=indent,eol,start        " allow backspacing over everything in insert mode
  7 "set ai            " always set autoindenting on
  8 "set backup        " keep a backup file
  9 set viminfo='20,"50    " read/write a .viminfo file, don't store more
 10             " than 50 lines of registers
 11 set history=50        " keep 50 lines of command line history
 12 set ruler        " show the cursor position all the time
 13 
 14 " Only do this part when compiled with support for autocommands
 15 if has("autocmd")
 16   augroup redhat
 17   autocmd!
 18   " In text files, always limit the width of text to 78 characters
 19   " autocmd BufRead *.txt set tw=78
 20   " When editing a file, always jump to the last cursor position
 21   autocmd BufReadPost *
 22    if line("'"") > 0 && line ("'"") <= line("$") |
 23      exe "normal! g'"" |
 24    endif
 25   " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
 26   autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
 27   " start with spec file template
 28   autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
 29   augroup END
 30 endif
 31 
 32 if has("cscope") && filereadable("/usr/bin/cscope")
 33    set csprg=/usr/bin/cscope
 34    set csto=0
 35    set cst
 36    set nocsverb
 37    " add any database in current directory
 38    if filereadable("cscope.out")
 39       cs add $PWD/cscope.out
 40    " else add database pointed to by environment
 41    elseif $CSCOPE_DB != ""
 42       cs add $CSCOPE_DB
 43    endif
 44    set csverb
 45 endif
 46 
 47 " Switch syntax highlighting on, when the terminal has colors
 48 " Also switch on highlighting the last used search pattern.
 49 if &t_Co > 2 || has("gui_running")
 50   syntax on
 51   set hlsearch
 52 endif
 53 
 54 filetype plugin on
 55 
 56 if &term=="xterm"
 57      set t_Co=8
 58      set t_Sb=m
 59      set t_Sf=m
 60 endif
 61 set fenc=utf-8
 62 set nocompatible
 63 "在处理未保存或者只读文件的时候 弹出确认"
 64 set confirm 
 65 "侦测文件类型"
 66 filetype plugin on
 67 set backspace=2
 68 "报告哪一行被改变了"
 69 
 70 set report=0
 71 set cursorline
 72 set backspace=2
 73 "禁止使用临时文件"
 74 set nobackup
 75 set noswapfile
 76 set autoread
 77 set autowrite
 78 set autoindent
 79 "使用鼠标"
 80 set mouse=a
 81 set selection=exclusive
 82 set selectmode=mouse,key
 83 set nu
 84 " Don't wake up system with blinking cursor:
 85 " http://www.linuxpowertop.org/known.php
 86 let &guicursor = &guicursor . ",a:blinkon0"
 87 noremap [ []<Esc>i
 88 inoremap [ []<Esc>i
 89 inoremap ( ()<Esc>i
 90 ""inoremap ) ()<Esc>i
 91 inoremap { {<CR>}<Esc>O
 92 inoremap } {<CR>}<Esc>O
 93 inoremap < <><Esc>i
 94 inoremap > <><Esc>i  
 95 inoremap " ""<Esc>i
 96 
 97 
 98 imap ,, <Esc>la
 99 imap .. <Esc>2la
100 
101 "复制粘贴"
102 map <c-a> <Esc>ggVGy
103 map <c-x> <Esc>ggVGd
104 ""map <c-v> <Esc>p
105 "ctags"
106 set tags=tags
107 set autochdir
108 
109 nmap tl :Tlist<CR>
110 let Tlist_Exit_OnlyWindow=1
111 let Tlist_Show_One_File = 1     " 只显示当前文件的tags
112 let Tlist_Exit_OnlyWindow = 1     "如果Taglist窗口是最后一个窗口则退出Vim
113 let Tlist_Use_Right_Window = 1       "在右侧窗口中显示
114 let Tlist_File_Fold_Auto_Close = 1     " 自动折叠
115 let Tlist_Auto_Open = 1         "默认打开taglist
116 let Tlist_Process_File_Always=1       " 实时更新tags
117 
118 inoremap ' ''<Esc>
View Code
原文地址:https://www.cnblogs.com/lanjianhappy/p/6020299.html