set nocompatible
source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim

"------------------------------------
"Other customizations I use with vim:
"  syntax highlighting for sql keywords
"  AutoFenc.vim plugin 
"--------------------------------------

"------------------------------------------------------------------------------------------
"sensible.vim settings
set backspace=indent,eol,start
set complete-=i
set showmatch

set ttimeout
set ttimeoutlen=50

set incsearch
set smartcase
" Use  to clear the highlighting of :set hlsearch.
if maparg('', 'n') ==# ''
  nnoremap   :nohlsearch
endif

set sidescrolloff=5
set display+=lastline

if &listchars ==# 'eol:$'
  set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
  if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8'
    let &listchars = "tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad"
    let &fillchars = "vert:\u259a,fold:\u00b7"
  endif
endif

set autoread
set autowrite
set fileformats=dos,unix,mac

set viminfo^=!

" Allow color schemes do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux'
  set t_Co=16
endif

if !exists('g:netrw_list_hide')
  let g:netrw_list_hide = '^\.,\~$,^tags$'
endif

" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
  runtime! macros/matchit.vim
endif

" Make Y consistent with C and D.  See :help Y.
nnoremap Y y$

"end sensible.vim settings
"------------------------------------------------------------------------------------------


"Tabs for indentation http://vim.wikia.com/wiki/VimTip1626
set copyindent
set preserveindent
set softtabstop=4
set shiftwidth=4
set expandtab
"set tabstop=4

"Some suggestions from Steve Losh [http://stevelosh.com/blog/2010/09/coming-home-to-vim/#why-i-switched-to-textmate]
set modelines=0
set scrolloff=3
"set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
"set visualbell
"set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
"set relativenumber

"others
set ignorecase


" font and line numbering (I read some coldfusion web dev files with long lines so font size of 9 is on the small side)
set guifont=consolas:h10
set number

"use utf-8 by default
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,ucs-2le,latin1

"always show status line
set laststatus=2

"use vbnet.vim syntax file for vb files
"autocmd BufNewFile,BufRead *.vb set ft=vbnet

"show encoding in status line http://vim.wikia.com/wiki/Show_fileencoding_and_bomb_in_the_status_line
if has("statusline")
 set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
endif
"set nobackup
"set nowritebackup
set backupdir=C:\myTemp\VimBackup
set directory=C:\myTemp\VimBackup

" colorscheme morning

if has("gui_running")
  " GUI is running or is about to start.
  " Maximize gvim window.
  set lines=50 columns=160
else
  " This is console Vim.
  if exists("+lines")
    set lines=50
  endif
  if exists("+columns")
    set columns=160
  endif
endif

" let &guioptions = substitute(&guioptions, "t", "", "g")
" behave mswin

" Custom Mappings (different escape key sequences)
inoremap aa 

" ----------------------------------------------------------
" Custom Mappings *when using behave mswin*
" To ensure arrow keys behave as normal
" vnoremap  h
" vnoremap  l
" vnoremap  k
" vnoremap  j

" ----------------------------------------------------------
" Custom Mappings *when not using behave mswin*
"" Disable the arrow keys in normal mode (learn to use hjkl)
nnoremap  
nnoremap  
nnoremap  
nnoremap  
"" Disable the arrow keys in insert mode
""   --learn to get back to normal mode when you
""   are done editing!
"inoremap  
"inoremap  
"inoremap  
"inoremap  
"" Tweak movement of j and k keys
nnoremap j gj
nnoremap k gk

" End customizations
" --------------------------------

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\ ' . arg3 . eq
endfunction