1 set nocompatible 2 "source $VIMRUNTIME/vimrc_example.vim 3 "source $VIMRUNTIME/mswin.vim 4 5 "-------------------------------------------------------------------------------------------- 6 "Other customizations I use with vim: 7 " syntax highlighting for sql keywords 8 " AutoFenc.vim (plugin for detecting file encoding) 9 " auto-pairs.vim (plugin for automatically closing parens/brackets/braces/quotes) 10 " mru.vim plugin (plugin to add most recently used files to file menu options) 11 " taglist.plugin (plugin for C programming) 12 "-------------------------------------------------------------------------------------------- 13 14 "-------------------------------------------------------------------------------------------- 15 "Note: this vimrc is a mishmash of various revisions. Still needs organizing and cleanup! 16 " You are expected to have a backup directory called .VimBackup in your home directory, 17 " otherwise, you will need to change the settings for backup directory and directory 18 " below. 19 "-------------------------------------------------------------------------------------------- 20 21 "-------------------------------------------------------------------------------------------- 22 "sensible.vim settings 23 set backspace=indent,eol,start 24 set complete-=i 25 set showmatch 26 27 set ttimeout 28 set ttimeoutlen=50 29 30 set incsearch 31 set smartcase 32 " Use <C-L> to clear the highlighting of :set hlsearch. 33 if maparg('<C-L>', 'n') ==# '' 34 nnoremap <silent> <C-L> :nohlsearch<CR><C-L> 35 endif 36 37 set sidescrolloff=5 38 set display+=lastline 39 40 if &listchars ==# 'eol:$' 41 set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ 42 if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8' 43 let &listchars = "tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad" 44 let &fillchars = "vert:\u259a,fold:\u00b7" 45 endif 46 endif 47 48 set autoread 49 set autowrite 50 set fileformats=unix,dos,mac 51 52 set viminfo^=! 53 54 " Allow color schemes do bright colors without forcing bold. 55 if &t_Co == 8 && $TERM !~# '^linux' 56 set t_Co=16 57 endif 58 59 if !exists('g:netrw_list_hide') 60 let g:netrw_list_hide = '^\.,\~$,^tags$' 61 endif 62 63 " Make Y consistent with C and D. See :help Y. 64 nnoremap Y y$ 65 66 "end sensible.vim settings 67 "-------------------------------------------------------------------------------------------- 68 69 70 "TAB OPTIONS ------------------------------------------------------------------------------ 71 "Option 1: Tabs are eight columns wide. Each indentation level is one tab. (Popular with the Linux kernel.) 72 "set tabstop=8 73 "set softtabstop=8 74 "set shiftwidth=8 75 "set noexpandtab 76 77 "Option 2: Tabs are four columns wide. Each indentation level is one tab. (Popular with Windows developers using Visual Studio.) 78 set tabstop=4 79 set softtabstop=4 80 set shiftwidth=4 81 set noexpandtab 82 83 "Option 3: Each indentation level is four spaces. Tabs are not used. (Popular with Java programmers) 84 "set softtabstop=4 85 "set shiftwidth=4 86 "set expandtab 87 88 "Option 4: Python 89 "set tabstop=4 90 "set shiftwidth=4 91 "set expandtab 92 "set softtabstop=4 93 autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab 94 "------------------------------------------------------------------------------------------ 95 96 97 "set copyindent 98 99 "turn on auto indent 100 set autoindent 101 "set preserveindent 102 103 104 105 "Some suggestions from Steve Losh [http://stevelosh.com/blog/2010/09/coming-home-to-vim/#why-i-switched-to-textmate] 106 set modelines=0 107 set scrolloff=3 108 "set autoindent 109 set showmode 110 set showcmd 111 set hidden 112 set wildmenu 113 set wildmode=list:longest 114 "set visualbell 115 "set cursorline 116 set ttyfast 117 set ruler 118 set backspace=indent,eol,start 119 "set relativenumber 120 121 "others 122 set ignorecase 123 set history=50 124 "set viminfo=%,'20,/100,:100,<500,f1,n~/.viminfo "find out what this means someday 125 126 "------------------------------------------------------------------------------------------ 127 "Print options 128 set printoptions=paper:letter,duplex:off,number:n "US Letter paper size, no duplex, no line numbers on printouts 129 " if you want to get line numbers printed: 130 " From within a vim session... First, check the contents of the 'printoptions' variable: 131 " :set printoptions 132 " If there is no 'number:' entry, add it: 133 " :set printoptions+=number:y 134 "------------------------------------------------------------------------------------------ 135 136 "enable reading of vimrc in the current directory (ex., to use a different indentation on your C source files) 137 set exrc 138 set secure 139 140 " font and line numbering (I read some coldfusion web dev files with long lines so font size of 9 is on the small side) 141 "set guifont=Monospace\ 11 142 set guifont=Ubuntu\ Mono\ 11 143 set number 144 145 "use utf-8 by default 146 set encoding=utf-8 147 set fileencodings=ucs-bom,utf-8,ucs-2le,latin1 148 149 "always show status line 150 set laststatus=2 151 152 "use vbnet.vim syntax file for vb files 153 "autocmd BufNewFile,BufRead *.vb set ft=vbnet 154 155 "show encoding in status line http://vim.wikia.com/wiki/Show_fileencoding_and_bomb_in_the_status_line 156 if has("statusline") 157 set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P 158 endif 159 "set nobackup 160 "set nowritebackup 161 set backupdir=~/.VimBackup 162 set directory=~/.VimBackup 163 164 " colorscheme morning 165 166 if has("gui_running") 167 " GUI is running or is about to start. 168 " Maximize gvim window. 169 set lines=44 columns=160 170 else 171 " This is console Vim. 172 if exists("+lines") 173 set lines=44 174 endif 175 if exists("+columns") 176 set columns=90 177 endif 178 endif 179 180 " let &guioptions = substitute(&guioptions, "t", "", "g") 181 " behave mswin 182 183 " Custom Mappings (different escape key sequences) 184 inoremap aa <Esc> 185 186 " ---------------------------------------------------------- 187 " Custom Mappings *when using behave mswin* 188 " To ensure arrow keys behave as normal 189 " vnoremap <Left> h 190 " vnoremap <Right> l 191 " vnoremap <Up> k 192 " vnoremap <Down> j 193 194 " ---------------------------------------------------------- 195 " Custom Mappings *when not using behave mswin* 196 "" Disable the arrow keys in normal mode (learn to use hjkl) 197 nnoremap <up> <nop> 198 nnoremap <down> <nop> 199 nnoremap <left> <nop> 200 nnoremap <right> <nop> 201 "" Disable the arrow keys in insert mode 202 "" --learn to get back to normal mode when you 203 "" are done editing! 204 " inoremap <up> <nop> 205 " inoremap <down> <nop> 206 " inoremap <left> <nop> 207 " inoremap <right> <nop> 208 "" Tweak movement of j and k keys 209 nnoremap j gj 210 nnoremap k gk 211 " End customizations 212 " -------------------------------- 213 214 set diffexpr=MyDiff() 215 function MyDiff() 216 let opt = '-a --binary ' 217 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif 218 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif 219 let arg1 = v:fname_in 220 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif 221 let arg2 = v:fname_new 222 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif 223 let arg3 = v:fname_out 224 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif 225 let eq = '' 226 if $VIMRUNTIME =~ ' ' 227 if &sh =~ '\<cmd' 228 let cmd = '""' . $VIMRUNTIME . '\diff"' 229 let eq = '"' 230 else 231 let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' 232 endif 233 else 234 let cmd = $VIMRUNTIME . '\diff' 235 endif 236 silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq 237 endfunction 238 239