" Chuan's vim config on Debian
" Part are adopted from the example config at:
" /usr/share/vim/vim64/vimrc_example.vim
" Last modifid: Dec 2011

" enable highlight
syntax on

" not like file end with ~
set nobackup

" use utf8 as default
set encoding=utf-8 " vim internal encoding
set fileencoding=utf-8 " new file encoding

" enable filetype setting
filetype plugin on
filetype indent on

" get function usage help automatically
set showfulltag
" show matching parentheses/brackets
set showmatch
" show current vim mode
set showmode

" set backgoud
set background=dark

" allow backspacing over everything in insert mode
set bs=2
" don't include character under cursor in selection
set selection=exclusive
" use a scrollable menu for filename completions
set wildmenu
" case-insensitive searching
set ignorecase


" indentation
set et
set ts=2
set sw=2
set autoindent
set smartindent

" Buffer Switching:
"   F2 = next buffer
"   F3 = previous buffer
"   F4 = kill buffer
inoremap <F2> <Esc>:bn<CR>
inoremap <F3> <Esc>:bp<CR>
inoremap <F4> <Esc>:bd<CR>
noremap <F2> <Esc>:bn<CR>
noremap <F3> <Esc>:bp<CR>
noremap <F4> <Esc>:bd<CR>

" Show line numbers
"   F12 = turn on/off line numbers
map <F12> :set nu!<CR>

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

set history=50    " keep 50 lines of command line history
set ruler   " show the cursor position all the time
set showcmd   " display incomplete commands
set incsearch   " do incremental searching

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  set hlsearch
endif

if has("gui_running")
  colorscheme evening
  if has("win32")
    set fileencodings=ucs-bom,utf-8,latin1
    set guifont=Consolas:h10:cANSI
    "set guifontwide=YaHei\ Consolas\ Hybrid:h10
  endif
endif