syntax on
noremap  <Up> ""
noremap! <Up> <Esc>
noremap  <Down> ""
noremap! <Down> <Esc>
noremap  <Left> ""
noremap! <Left> <Esc>
noremap  <Right> ""
noremap! <Right> <Esc>

" then define two autocommands
"au InsertEnter * hi StatusLine term=reverse guibg=#005000
"au InsertLeave * hi StatusLine term=reverse guibg=#444444
set number
set tw=79
set encoding=utf-8
setglobal fileencoding=utf-8
set nobomb
set termencoding=utf-8
set fileencodings=utf-8,iso-8859-15
set backspace=indent,eol,start
set guifont=Monaco:h16
set modeline
"set statusline=%F%m%r%h%w\ [\%03.3b]\ [\%02.2B]\ [l%l,c%v][%p%%]\ [%L]

set laststatus=2

set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set smarttab
set expandtab
autocmd FileType make setlocal noexpandtab

let Tlist_Inc_Winwidth = 0

if has("autocmd") 
    au BufReadPost * if &modifiable | retab | endif 
endif 

set showcmd
set nocompatible

" Enable mouse support in console
set mouse=a

set ignorecase
set smartcase
inoremap jj <Esc>
"set incsearch
"set hlsearch

map N Nzz
map n nzz

" map _t :TlistToggle<cr>

colorscheme koehler
"set cul
"hi CursorLine term=none cterm=none ctermbg=none
"set t_Co=256


" folding setup
set foldmethod=indent
"set foldnestmax=10      "deepest fold is 10 levels
set foldminlines=3
"set nofoldenable        "dont fold by default
"set foldlevel=1         "this is just what i use
nnoremap <silent> <Space> @=(foldlevel('.')?'za':'l')<CR>
vnoremap <Space> zf
"au BufWinLeave * mkview
"au BufWinEnter * silent loadview


if has('statusline')
   " Status line detail:
   " %f     file path
   " %y     file type between braces (if defined)
   " %([%R%M]%)   read-only, modified and modifiable flags between braces
   " %{'!'[&ff=='default_file_format']}
   "        shows a '!' if the file format is not the platform
   "        default
   " %{'$'[!&list]}  shows a '*' if in list mode
   " %{'~'[&pm=='']} shows a '~' if in patchmode
   " (%{synIDattr(synID(line('.'),col('.'),0),'name')})
   "        only for debug : display the current syntax item name
   " %=     right-align following items
   " #%n    buffer number
   " %l/%L,%c%V   line number, total number of lines, and column number
   function SetStatusLineStyle()
      if &stl == '' || &stl =~ 'synID'
         let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]}%{'~'[&pm=='']}%=#%n %l/%L,%c%V "
      else
         let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]} (%{synIDattr(synID(line('.'),col('.'),0),'name')})%=#%n %l/%L,%c%V "
      endif
   endfunc
   " Switch between the normal and vim-debug modes in the status line
   nmap _ds :call SetStatusLineStyle()<CR>
   call SetStatusLineStyle()
   " Window title
   if has('title')
      set titlestring=%t%(\ [%R%M]%)
   endif
endif
