syntax on

set background=dark
set mouse=a
set hidden
set showmode
set showcmd
set linebreak

set nobackup
set nowb
set noswapfile

set nocompatible              " vim, not vi
set autoread                  " watch for file changes
set number                    " line numbers
set more                      " use more prompt
set noautowrite               " don't automagically write on :next
set lazyredraw                " don't redraw when don't have to

" Tabs
set tabstop=2                 " 2 spaces
set shiftwidth=2              " 2 spaces in insertmode
set autoindent smartindent    " auto/smart indent
set expandtab
set smarttab

" Statusbar
set laststatus=2              " Always show a status line
set ruler                     " show the line number on the bar
set cmdheight=2               " command line two lines high
set wildmenu                  " menu has tab completion
set wildmode=longest:full
set statusline=%t%h%m%r%=[%b\ 0x%02B]\ \ \ %l,%c%V\ %P

set scrolloff=5               " keep at least 5 lines above/below
set sidescrolloff=5           " keep at least 5 lines left/right

set backspace=indent,eol,start
set shell=bash
set history=200
set undolevels=1000           " 1000 undos
set complete=.,w,b,u,U,t,i,d  " do lots of scanning on tab completion
set updatecount=100           " switch every 100 chars
set ttyfast                   " we have a fast terminal
set noerrorbells              " No error bells please

filetype on                   " Enable filetype detection
filetype indent on            " Enable filetype-specific indenting
filetype plugin on            " Enable filetype-specific plugins

" Searching
set incsearch                 " incremental search
set ignorecase                " search ignoring case
set hlsearch                  " highlight the search
set showmatch                 " show matching bracket
set diffopt=filler,iwhite     " ignore all whitespace and sync
set cmdheight=1               " make the command line 1 line high

" Encoding
set ff=unix
set nobomb
set encoding=utf-8
set fileformats=unix
set termencoding=utf-8
set fileencodings=utf-8,iso-8859-15
setglobal fileencoding=utf-8

" Spelling
if v:version >= 700
  " Enable spell check for text files
  autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en
endif

" toggle list mode
nmap <LocalLeader>tl :set list!<cr>
" toggle paste mode
nmap <LocalLeader>pp :set paste!<cr>

" window managment
nmap w <C-w>

" Map <Space> to / (search) and Ctrl-<Space> to ? (backward search)
map <space> /
map <c-space> ?

" bubble single lines
nmap <S-j> ddkP
nmap <S-k> ddp
" bubble multiple lines
vmap <S-j> xkP`[V`]
vmap <S-k> xp`[V`]
