"""""""""""""""""""""""""""""""
"                             "
"          MISC VIM           "
"                             "
"""""""""""""""""""""""""""""""

set showmode          "Always show mode
set history=700       "Sets how many lines of history VIM has to remember
set ttimeoutlen=50    "Speed up O etc in the Terminal
set autoread          "Set to auto read when a file is changed from the outside
set bs=2              "allow backspace
set scrolloff=6       "start scrolling 5 lines before edge of viewport


"Search Options
set ignorecase "Ignore case when searching
set incsearch  "Make search act like search in modern browsers
set magic      "Set magic on, for regular expressions

"Turn backup off
set nobackup
set nowb
set noswapfile


"""""""""""""""""""""""""""""""
"                             "
"     Spacing and Lines       "
"                             "
"""""""""""""""""""""""""""""""

"Show cursorline
set nocursorline

"Toggle cursorline on F8
nnoremap <f8> :set invcursorline cursorline?<CR>

"Show line numbers
set number

"Toggle line numbers on F9
nnoremap <f9> :set invnumber number?<CR>

"Set paste mode
set paste

"Toggle paste mode on F10
nnoremap <f10> :set invpaste paste?<CR>

"Transform tabs to spaces
set expandtab

"Other tabs settings
set smarttab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set shiftround

"Code formatting
set noautoindent

"Toggle autoindent mode on F7
nnoremap <f7> :set invautoindent autoindent?<CR>

"Line Wrapping
set wrap

"Use system clipboard
set clipboard=unnamed

"Disable bell and flashing
set noerrorbells visualbell t_vb=

"Set lines to yank between files
set viminfo+=<1000


"""""""""""""""""""""""""""""""
"                             "
"     Statusline              "
"                             "
"""""""""""""""""""""""""""""""

let g:currentmode={
  \ 'n'  : 'Normal',
  \ 'no' : 'Normal Operator Pending',
  \ 'v'  : 'Visual',
  \ 'V'  : 'V-Line',
  \ '^V' : 'V-Block',
  \ 's'  : 'Select',
  \ 'S'  : 'S-Line',
  \ '^S' : 'S-Block',
  \ 'i'  : 'Insert',
  \ 'R'  : 'Replace',
  \ 'Rv' : 'V-Replace',
  \ 'c'  : 'Command',
  \ 'cv' : 'Vim Ex',
  \ 'ce' : 'Ex',
  \ 'r'  : 'Prompt',
  \ 'rm' : 'More',
  \ 'r?' : 'Confirm',
  \ '!'  : 'Shell',
  \ 't'  : 'Terminal'
  \}

set laststatus=2

hi User1 ctermbg=green ctermfg=red   guibg=green guifg=red
hi User2 ctermbg=red   ctermfg=white guibg=red   guifg=white
hi User3 ctermbg=blue  ctermfg=green guibg=blue  guifg=green
hi User4 ctermbg=cyan  ctermfg=black guibg=cyan  guifg=black 
hi User5 ctermbg=blue  ctermfg=black guibg=blue  guifg=black

set statusline=
set statusline+=%1* "switch to User1 highlight
set statusline+=[%n%H%M%R%W]%*
set statusline+=%3* "switch to User3 highlight
set statusline+=\ %-40F

set statusline+=%= "move to right

set statusline+=%5* "switch to User5 highlight
set statusline+=\ F7=autoindent "user help
set statusline+=\ F8=cline "user help
set statusline+=\ F9=numbers "user help
set statusline+=\ F10=paste\ "user help

set statusline+=%2* "switch to User2 highlight
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\ [%{&fileformat}\]
set statusline+=\ %8((%l,%c)%)
set statusline+=\ %P\ "percent and space at end off string
set statusline+=%4* "switch to User4 highlight
set statusline+=\ %{toupper(g:currentmode[mode()])}\ "The current mode
