~/vimrc
1 # ~/ [http://www.devil.mk.ua/] - home directory 2 # ~/.zsh - zsh config 3 # ~/screenshots - screenshots gallery 4 # ~/torsmorc - torsmo configuration and scripts 5 # ~/vimrc - vim configuration 6 # ~/about - about me 1 scriptencoding utf - 8 2 "----------------------------------------------------------------------- 3 " terminal setup 4 "----------------------------------------------------------------------- 5 6 " Extra terminal things 7 if ( $TERM == "rxvt-unicode" ) && ( &termencoding == "" ) 8 set termencoding =utf-8 9 endif 10 11 set autoindent 12 set nocompatible 13 set ruler 14 set showcmd 15 set statusline =%=%f\ \"%F\"\ %m%R\ [%4l(%3p%%) : %3c-(0x%2B , \0%2b) , %Y , %{&encoding}] 16 set tabstop =4 17 set shiftwidth =4 18 set smarttab 19 set expandtab 20 colors default 21 syntax on 22 set hlsearch 23 set incsearch 24 set nowrap 25 set listchars +=precedes : < , extends : > 26 set sidescroll =5 27 set sidescrolloff =5 28 set backspace =indent , eol , start 29 set nobackup 30 filetype plugin indent on 31 32 " Show full tags when doing search completion 33 set showfulltag 34 35 " Speed up macros 36 set lazyredraw 37 38 " No annoying error noises 39 set noerrorbells 40 set visualbell t_vb = 41 autocmd GUIEnter * set visualbell t_vb = 42 43 " Try to show at least three lines and two columns of context when 44 " scrolling 45 set scrolloff =3 46 set sidescrolloff =2 47 " Wrap on these 48 set whichwrap += < , > , [ , ] 49 50 " Use the cool tab complete menu 51 set wildmenu 52 set wildignore =*.o , *~ 53 54 " Allow edit buffers to be hidden 55 set hidden 56 " 1 height windows 57 set winminheight =1 58 " Set our fonts 59 if has ( "gui_kde" ) 60 set guifont =Terminus/12/-1/5/50/0/0/0/0/0 61 elseif has ( "gui_gtk" ) 62 set guifont =Terminus\ 12 63 elseif has ( "gui_running" ) 64 set guifont =-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso10646-1 65 endif 66 " Try to load a nice colourscheme 67 fun ! LoadColourScheme ( schemes ) 68 let l:schemes = a:schemes . ":" 69 while l:schemes != "" 70 let l:scheme = strpart ( l:schemes, 0 , stridx ( l:schemes, ":" )) 71 let l:schemes = strpart ( l:schemes, stridx ( l:schemes, ":" ) + 1 ) 72 try 73 exec "colorscheme" l:scheme 74 break 75 catch 76 endtry 77 endwhile 78 endfun 79 80 if has ( 'gui' ) 81 call LoadColourScheme ( "inkpot:night:rainbow_night:darkblue:elflord" ) 82 else 83 if &t_Co == 88 || &t_Co == 256 84 call LoadColourScheme ( "inkpot:darkblue:elflord" ) 85 else 86 call LoadColourScheme ( "darkblue:elflord" ) 87 endif 88 endif 89 90 " No icky toolbar, menu or scrollbars in the GUI 91 if has ( 'gui' ) 92 set guioptions -=m 93 set guioptions -=T 94 set guioptions -=l 95 set guioptions -=L 96 set guioptions -=r 97 set guioptions -=R 98 end 99 100 " Do clever indent things. Don't make a # force column zero. 101 set autoindent 102 set smartindent 103 inoremap # X < BS > # 104 105 " Enable folds 106 set foldenable 107 set foldmethod =indent 108 109 " Syntax when printing 110 set popt +=syntax : y 111 112 " Enable filetype settings 113 filetype on 114 filetype plugin on 115 filetype indent on 116 117 " Enable modelines only on secure vim versions 118 if ( v:version == 603 && has ( "patch045" )) || ( v:version > 603 ) 119 set modeline 120 else 121 set nomodeline 122 endif 123 124 125 " If possible, try to use a narrow number column. 126 if v:version >= 700 127 try 128 setlocal numberwidth =3 129 catch 130 endtry 131 endif 132 133 " Include $HOME in cdpath 134 let &cdpath = ',' . expand ( "$HOME" ) 135 136 " Show tabs and trailing whitespace visually 137 if ( &termencoding == "utf-8" ) || has ( "gui_running" ) 138 if v:version >= 700 139 set list listchars =tab : »· , trail : · , extends : … , nbsp :
<80><97> 140 else 141 set list listchars =tab : »· , trail : · , extends : <80> 142 endif 143 else 144 if v:version >= 700 145 set list listchars =tab : >- , trail : . , extends : > , nbsp : _ 146 else 147 set list listchars =tab : >- , trail : . , extends : > 148 endif 149 endif 150 151 set fillchars =fold : - 152 153 "----------------------------------------------------------------------- 154 " completion 155 "----------------------------------------------------------------------- 156 set dictionary =/usr/share/dict/words 157 158 "----------------------------------------------------------------------- 159 " autocmds 160 "----------------------------------------------------------------------- 161 162 " If we're in a wide window, enable line numbers. 163 fun ! WindowWidth () 164 if winwidth ( 0 ) > 90 165 setlocal foldcolumn =1 166 setlocal number 167 else 168 setlocal nonumber 169 setlocal foldcolumn =0 170 endif 171 endfun 172 173 " Force active window to the top of the screen without losing its 174 " size. 175 fun ! WindowToTop () 176 let l: h = winheight ( 0 ) 177 wincmd K 178 execute "resize" l:h 179 endfun 180 181 " Force active window to the bottom of the screen without losing its 182 " size. 183 fun ! WindowToBottom () 184 let l: h = winheight ( 0 ) 185 wincmd J 186 execute "resize" l:h 187 endfun 188 189 " Update .*rc header 190 fun ! UpdateRcHeader () 191 let l: c = col ( "." ) 192 let l: l = line ( "." ) 193 1 , 10 s - \ ( Most recent update:\ ). * - \ = "Most recent update: " . strftime ( "%c" )- e 194 call cursor ( l:l, l:c ) 195 endfun 196 197 198 " Perl specific options 199 let perl_include_pod = 1 200 let perl_fold = 1 201 let perl_fold_blocks = 1 202 203 " Vim specific options 204 let g:vimsyntax_noerror = 1 205 206 " Settings for taglist.vim 207 let Tlist_Use_Right_Window = 1 208 let Tlist_Auto_Open = 0 209 let Tlist_Enable_Fold_Column = 0 210 let Tlist_Compact_Format = 1 211 let Tlist_WinWidth = 28 212 let Tlist_Exit_OnlyWindow = 1 213 let Tlist_File_Fold_Auto_Close = 1 214 nnoremap < silent > < F9 > :Tlist < CR > 215 216 " Settings minibufexpl.vim 217 let g:miniBufExplModSelTarget = 1 218 let g:miniBufExplWinFixHeight = 1 219 " let g:miniBufExplForceSyntaxEnable = 1 220 221 " Settings for showmarks.vim 222 if has ( "gui_running" ) 223 let g:showmarks_enable = 1 224 else 225 let g:showmarks_enable = 0 226 let loaded_showmarks = 1 227 endif 228 229 autocmd VimEnter * 230 \ if has ( 'gui' ) | 231 \ highlight ShowMarksHLl gui = bold guifg = #a0a0e0 guibg = #2e2e2e | 232 \ highlight ShowMarksHLu gui = none guifg = #a0a0e0 guibg = #2e2e2e | 233 \ highlight ShowMarksHLo gui = none guifg = #a0a0e0 guibg = #2e2e2e | 234 \ highlight ShowMarksHLm gui = none guifg = #a0a0e0 guibg = #2e2e2e | 235 \ highlight SignColumn gui = none guifg = #f0f0f8 guibg = #2e2e2e | 236 \ endif 237 238 " Settings for explorer.vim 239 let g:explHideFiles = '^\.' 240 241 " Settings for netrw 242 let g:netrw_list_hide = '^\.,\~$' 243 244 " Settings for :TOhtml 245 let html_number_lines = 1 246 let html_use_css = 1 247 let use_xhtml = 1 248 249 " cscope settings 250 if has ( 'cscope' ) && filereadable ( "/usr/bin/cscope" ) 251 set csto =0 252 set cscopetag 253 set nocsverb 254 if filereadable ( "cscope.out" ) 255 cs add cscope . out 256 endif 257 set csverb 258 259 let x = "sgctefd" 260 while x != "" 261 let y = strpart ( x, 0 , 1 ) | let x = strpart ( x, 1 ) 262 exec "nmap " . y . " :cscope find " . y . 263 \ " =expand(\"\\")" 264 exec "nmap " . y . " :scscope find " . y . 265 \ " =expand(\"\\")" 266 endwhile 267 nmap < C-j > i :cscope find i ^ < C-R > = expand ( "" ) < CR >< CR > 268 nmap < C-j >< C-j > i :scscope find i ^ < C-R > = expand ( "" ) < CR >< CR > 269 endif 270 271 "----------------------------------------------------------------------- 272 " final commands 273 "----------------------------------------------------------------------- 274 275 " turn off any existing search 276 au VimEnter * nohls 277 278 "----------------------------------------------------------------------- 279 " vim: set shiftwidth=4 softtabstop=4 expandtab tw=72 : 280 " 281 " перекодировка 282 let b:encindex = 0 283 function ! RotateEnc () 284 let y = - 1 285 while y == - 1 286 let encstring = "#8bit-cp1251#8bit-cp866#utf-8#koi8-r#" 287 let x = match ( encstring, "#" ,b:encindex ) 288 let y = match ( encstring, "#" ,x + 1 ) 289 let b:encindex = x + 1 290 if y == - 1 291 let b:encindex = 0 292 else 293 let str = strpart ( encstring,x + 1 ,y - x - 1 ) 294 return ":set encoding=" . str 295 endif 296 endwhile 297 endfunction 298 299 "autocmd FileType text setlocal textwidth=78 300 " автодополнение фигурной скобки (так, как я люблю :) 301 imap { < CR > { < CR > } < Esc > O < Tab > 302 303 " автодополнение по Control+Space 304 "imap 305 " 'умный' Home 306 nmap < Home > ^ 307 imap < Home > < Esc > I 308 309 " выход 310 "imap :qa 311 "nmap :qa 312 313 " сохранение текущего буфера 314 imap < F2 > < Esc > : w < CR > a 315 nmap < F2 > : w < CR > 316 317 " сохранение всех буферов 318 imap < S-F2 > < Esc > : wa < CR > a 319 nmap < S-F2 > : wa < CR > 320 321 " список буферов 322 "imap :buffers 323 "nmap :buffers 324 325 " закрыть буфер 326 "imap :bda 327 "nmap :bd 328 329 " открыть буфер 330 "imap :e 331 "nmap :e 332 333 " следующий буфер 334 imap < F6 > < Esc > : bn ! < CR > a 335 nmap < F6 > : bn ! < CR > 336 337 " предыдущий буфер 338 imap < F5 > < Esc > : bp ! < CR > a 339 nmap < F5 > : bp ! < CR > 340 " перекодировка 341 map < F8 > : execute RotateEnc () 342 343 " окно ниже и развернуть 344 "imap j_a 345 "nmap j_ 346 347 " окно выше и развернуть 348 "imap k_a 349 "nmap k_ 350 351 " окно ниже 352 "imap ja 353 "nmap j 354 355 " окно выше 356 "imap ka 357 "nmap k 358 359 " окно левее 360 "imap ha 361 "nmap h 362 363 " окно правее 364 "imap la 365 "nmap l 366 367 " сборка с сохранением 368 "imap :wa:make 369 "nmap :wa:make 370 371 " пересборка с сохранением 372 "imap :wa:makeclean:make 373 "nmap :wa:makeclean:make 374 375 " открыть окно результатов компиляции 376 "imap :copen 377 "nmap :copen 378 379 " следующая ошибка 380 "imap :cni 381 "nmap :cn 382 383 " предыдущая ошибка 384 "imap :cpi 385 "nmap :cp 386 387 " вкл/выкл отображения номеров строк 388 imap < F1 > < Esc > : set < Space > nu ! < CR > a 389 nmap < F1 > : set < Space > nu ! < CR > 390 391 " вкл/выкл отображения найденных соответствий 392 imap < S-F1 > < Esc > : set < Space > hls! < CR > a 393 nmap < S-F1 > : set < Space > hls! < CR > 394 395 set showmatch " проверка скобок 396 set history =500 " увеличение истории команд 397 filetype plugin on 398 filetype indent on 399 set undolevels =500 400 set ttyfast # vim: set noet ts= 4 tw= 80 :