1 " 2 " @(#) This is vimrc for vim/gvim. 3 " This vimrc file will automatically configure itself based on 4 " the system it runs on (Windows/Unix). 5 " This vimrc file has been tested on SPARC/Solaris, Intel/Linux 6 " and Windows NT/ME 7 " 8 " Config Notes: 9 " Unix: 10 " 1. Create a directory: ~/vimtmp and move .viminfo there 11 " 2. Link: ln -s .vimrc .gvimrc 12 " 3. If gvim is executed, .vimrc will be executed twice. 13 " First as .vimrc and then as .gvimrc. This is good! 14 " Windows: 15 " 1. Create a directory: $HOME\vimtmp 16 " 2. Move .viminfo (if it exists) to $HOME\vimtmp 17 " 3. Name .vimrc as _vimrc in $HOME 18 " 19 " Make sure there is no _gvimrc in $HOME. This creates a conflict. 20 " 4. Optional. In the Windows Global settings below, change the preferences 21 " to suit your needs. 22 " 23 " @(#) 01/07/25-03/07/21 xaos@darksmile.net, "http://www.darksmile.net/vimindex.html" 24 " 25 " Windows Global Settings. Font and scheme preferences 26 " 27 let mywinfont="Lucida_Console:h12:cANSI" 28 let $myscheme=$VIMRUNTIME . '\colors\koehler.vim' 29 let $myxscheme=$VIMRUNTIME . '/colors/koehler.vim' 30 " 31 " If full gui has been reached then run these additional commands. Unix only! 32 " 33 if has("gui_running") && &term == "builtin_gui" 34 if &syntax == "" && isdirectory($VIMRUNTIME) 35 syntax on 36 set hlsearch 37 endif 38 map <F37> :set list!^M 39 imap <F37> ^[:set list!^Ma 40 highlight Normal guibg=white 41 highlight Cursor guibg=green guifg=NONE 42 set guifont=-schumacher-clean-medium-r-normal-*-*-160-*-*-c-*-iso646.1991-irv 43 " 44 " This is also nice. Run as :F2 to change font 45 command! F2 set guifont=-dec-terminal-medium-r-wide-*-*-140-*-*-c-*-iso8859-1 46 if filereadable( $myxscheme ) 47 source $myxscheme 48 endif 49 else 50 " 51 " This needs to be set up front 52 " 53 set nocompatible 54 " 55 " Set up according to platform 56 " 57 if has("win32") || has("win16") 58 let osys="windows" 59 behave mswin 60 source $VIMRUNTIME/mswin.vim 61 else 62 let osys=system('uname -s') 63 " 64 " What was the name that we were called as? 65 " 66 let vinvoke=fnamemodify($_, ":p") 67 let fullp=substitute(vinvoke, '^\(.*[/]\).*$', '\1', "") 68 " 69 " It's possible that $VIMRUNTIME does not exist. 70 " Let's see if there is a dir vimshare below where we were started 71 " 72 if isdirectory($VIMRUNTIME) == 0 73 let vimshare=fullp . "vimshare" 74 if isdirectory(vimshare) == 1 75 let $VIMRUNTIME=vimshare . "/vim" . substitute(v:version, "50", "5", "") 76 let &helpfile=vimshare . "/vim" . substitute(v:version, "50", "5", "") . "/doc/help.txt" 77 endif 78 endif 79 endif 80 if &t_Co > 2 81 set bg=dark 82 syntax on 83 set nohlsearch 84 highlight Comment term=bold ctermfg=2 85 highlight Constant term=underline ctermfg=7 86 endif 87 if osys == "windows" && has("gui_running") 88 syntax on 89 set hlsearch 90 let &guifont=mywinfont 91 if filereadable( $myscheme ) 92 source $myscheme 93 endif 94 endif 95 if version >= 600 96 filetype plugin indent on 97 autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif 98 " 99 " fold options 100 " 101 "set foldmethod=indent 102 "set foldmethod=expr 103 "set foldexpr=getline(v:lnum)[0]==\"\\t\" 104 else 105 autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif 106 endif 107 " 108 " Find out where the backups and viminfo are kept 109 " If term is blank at this point, this must be a windows system 110 " 111 if osys == "windows" 112 let vimtdir=$HOME . '\vimtmp' 113 if isdirectory(vimtdir) == 0 114 let vimtdir=$HOME 115 endif 116 let &viminfo="'20," . '%,n' . vimtdir . '\.viminfo' 117 else 118 let myuid=substitute(system('id'), '^uid=\([0-9]*\)(.*', '\1', "") 119 let vimtdir=$HOME . '/vimtmp' 120 if isdirectory(vimtdir) == 0 121 let vimtdir=$HOME 122 endif 123 if myuid == "0" && osys =~ "SunOS" 124 let vimtdir='/var/vimtmp' 125 endif 126 let &viminfo="'20," . '%,n' . vimtdir . '/.viminfo' 127 " 128 " Setup a proper include file path 129 " 130 if $INCLUDE == "" 131 if osys =~ "SunOS" 132 let &path="/usr/include,/usr/openwin/include,/usr/dt/include,/usr/local/include" 133 else 134 let &path="/usr/include,/usr/X11R6/include,/usr/openwin/include,/usr/local/include" 135 endif 136 else 137 let &path=substitute($INCLUDE, ':', ',', "g") 138 endif 139 endif 140 set backup 141 let &backupdir=vimtdir 142 set history=100 143 set number 144 set nowrap 145 set tabstop=4 146 set shiftwidth=4 147 set statusline=%<%F%h%m%r%=\[%B\]\ %l,%c%V\ %P 148 set laststatus=2 149 set showcmd 150 set gcr=a:blinkon0 151 set errorbells 152 set visualbell 153 set nowarn 154 set ignorecase 155 set smartcase 156 " 157 " The following function and maps allow for [[ and ]] to search for a 158 " single char under the cursor. 159 " 160 function Cchar() 161 let c = getline(line("."))[col(".") - 1] 162 let @/ = c 163 endfunction 164 map [[ :call Cchar()^Mn 165 map ]] :call Cchar()^MN 166 " 167 " Use F4 to switch between hex and ASCII editing 168 " 169 function Fxxd() 170 let c=getline(".") 171 if c =~ '^[0-9a-f]\{7}:' 172 :%!xxd -r 173 else 174 :%!xxd -g4 175 endif 176 endfunction 177 map <F4> :call Fxxd()^M 178 map ^_ gf 179 if &term == "xterm" 180 " Delete 181 map ^V^? x 182 " End 183 map ^[[26~ 100% 184 " Home 185 map ^[[25~ :1^M 186 " F2 187 map ^[[12~ :w^M 188 imap ^[[12~ ^[:w^Mi 189 " F3 190 map ^[[13~ :q^M 191 imap ^[[13~ ^[:q^M 192 " F10 193 map ^[[21~ :wq!^M 194 imap ^[[21~ ^[:wq!^M 195 " F11 196 map ^V^[[24~ :set list!^M 197 imap ^V^[[24~ ^[:set list!^Mi 198 else 199 if osys != "windows" 200 map ^V^[[3~ x " Delete 201 imap ^V^[[3~ ^H 202 map ^V^[[2~ i " Insert 203 imap ^V^[[2~ ^V^[ 204 map ^V^[[4~ 100% " End 205 map ^V^[[1~ :1^M " Home 206 map ^V^[[5~ ^V^B " PgUp 207 map ^V^[[6~ ^V^F " PgDn 208 map ^[[[A :h^M " F1 209 map ^[[28~ :h^M 210 endif 211 endif 212 map <F2> :w^M 213 imap <F2> ^[:w^Ma 214 map <F3> :q^M 215 imap <F3> ^[:q^M 216 map <F10> :wq!^M 217 imap <F10> ^[:wq!^M 218 endif 219 " 220 " Some commands which must be run twice! 221 " 222 if version >= 600 223 set cmdwinheight& 224 endif 225 set cmdheight&