set nocompatible        " use vim defaults
set ls=1                " allways show status line
set tabstop=4           " numbers of spaces of tab character
set shiftwidth=4        " numbers of spaces to (auto)indent
set scrolloff=3         " keep 3 lines when scrolling
set showcmd             " display incomplete commands
set hlsearch            " highlight searches
set incsearch           " do incremental searching
set ruler               " show the cursor position all the time
set nobackup            " do not keep a backup file
"set number             " show line numbers
"set ignorecase         " ignore case when searching 
set noignorecase        " don't ignore case
set title               " show title in console title bar
set ttyfast             " smoother changes
set modeline            " last lines in document sets vim mode
set modelines=3         " number lines checked for modelines
set shortmess=atI       " Abbreviate messages
set nostartofline       " don't jump to first character when paging
set sm                  " show matching braces
set virtualedit=block   "By default, vim doesn't let the cursor stray beyond the defined text. This setting allows the cursor to freely roam anywhere it likes in command mode. It feels weird at first but is quite useful.

set hidden              "Change buffer - without saving
set magic               "magic regex

"Auto indent
set ai

"Smart indet
set si

"C-style indeting
set cindent

set wildmenu
set wildmode=longest:full


"set autowrite          " auto saves changes when quitting and swiching buffer
"set expandtab          " tabs are converted to spaces, use only when required
"set nowrap             " don't wrap lines

"Enable filetype plugin
filetype plugin on
filetype indent on

syntax on               " syntax highlighing
if has("gui_running")
    "See ~/.gvimrc
    set guifont=Monospace 10        " use this font 
    set lines=50                    " height = 50 lines
    set columns=100                 " width = 100 columns
    set background=light            " adapt colors for background
    "set selectmode=mouse,key,cmd
    set keymodel=
else
    colorscheme elflord             " use this color scheme
    set background=dark             " adapt colors for background
endif

if has("autocmd")
    " Restore cursor position
    au BufReadPost * if line("'"") > 0|if line("'"") <= line("$")|exe("norm '"")|else|exe "norm $"|endif|endif

    " Filetypes (au = autocmd)
    au FileType helpfile set nonumber      " no line numbers when viewing help
    au FileType helpfile nnoremap <buffer><cr> <c-]>   " Enter selects subject
    au FileType helpfile nnoremap <buffer><bs> <c-T>   " Backspace to go back
    
    " When using mutt, text width=72
    au FileType mail,tex set textwidth=72
    au FileType cpp,c,java,sh,pl,php,asp  set autoindent
    au FileType cpp,c,java,sh,pl,php,asp  set smartindent
    au FileType cpp,c,java,sh,pl,php,asp  set cindent
    "au BufRead mutt*[0-9] set tw=72
    
    " Automatically chmod +x Shell and Perl scripts
    "au BufWritePost   *.sh             !chmod +x %
    "au BufWritePost   *.pl             !chmod +x %

    " File formats
    au BufNewFile,BufRead  *.pls    set syntax=dosini
    au BufNewFile,BufRead  modprobe.conf    set syntax=modconf
endif

" Common command line typos
cmap W w
cmap Q q


set notitle  "disable 'Thanks for flying vim' xterm title