本文只介绍一些最常用的基础配置,以改进 vim 的初始状态。
更多高级配置,可以自行搜索、完善。
拷贝以下内容到 ~/.vimrc
文件中,没有此文件请自行创建。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""基本设置""""""""""
set nocompatible
set nu highlight LineNr cterm=bold ctermfg=darkgray
syntax on
set paste
set cursorline
set history=100
set confirm
set iskeyword+=_,$,@,%,#,-
set list lcs=tab:>-,trail:-
set nobackup set noswapfile
set autoread
""""""""""搜索和匹配设置""""""""""
set hlsearch hi Search cterm=NONE ctermfg=darkred ctermbg=yellow cterm=reverse
set ignorecase
set incsearch
set wrapscan
set matchtime=5
""""""""""文本操作设置""""""""""
set tabstop=4 set softtabstop=4 set shiftwidth=4
set smartindent
set expandtab
set autoindent
set fileencodings=utf-8,gb2312,usc-bom,cp936,euc-cn set termencoding=utf-8 set encoding=utf-8
""""""""""底部状态条设置""""""""""
set laststatus=2 set statusline= set statusline+=%7*\[%n] set statusline+=%1*\ %<%F\ set statusline+=%2*\ %y\ set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ " 编码2 set statusline+=%4*\ %{&ff}\ set statusline+=%5*\ %{&spelllang}\%{HighlightSearch()}\ set statusline+=%8*\ %=\ row:%l/%L\ (%03p%%)\ set statusline+=%9*\ col:%03c\ set statusline+=%0*\ \ %m%r%w\ %P\ \ function! HighlightSearch() if &hls return 'H' else return '' endif endfunction hi User1 ctermfg=white ctermbg=darkred hi User2 ctermfg=blue ctermbg=58 hi User3 ctermfg=white ctermbg=100 hi User4 ctermfg=darkred ctermbg=95 hi User5 ctermfg=darkred ctermbg=77 hi User7 ctermfg=darkred ctermbg=138 cterm=bold hi User8 ctermfg=231 ctermbg=darkgray
hi User0 ctermfg=yellow ctermbg=138
""""""""""其它""""""""""
|