call pathogen#infect() 
" Pathogen

filetype plugin indent on
set omnifunc=syntaxcomplete#Complete

" conceal displays LaTeX formulars inline with UTF8
set conceallevel=0 " 1,2 to enable it
set concealcursor=

set linebreak

"set wrap
set nowrap

set noswapfile
"set noundofile
"set nobackup
"set nowritebackup
set backupdir=~/.vim/temp
set directory=~/.vim/temp
set undodir=~/.vim/temp

" [code completion]
set completeopt=longest,menuone

" [spell checker]
"set spell " enable spell checking
set spelllang=en,de

set guifont=DejaVu\ Sans\ Mono\ bold\ 11
"set guifont=Liberation\ Mono\ for\ Powerline\ 11



" [Kopieren und Einfuegen]
" verwendet das x-window-clipboard <3
set clipboard=unnamedplus
"set clipboard=autoselectplus


" [SUCHEN]
" When 'ignorecase' and 'smartcase' are both on, if a pattern contains an uppercase letter, it is case sensitive, otherwise, it is not. For example, /The would find only "The", while /the would find "the" or "The" etc. 
set ignorecase
set smartcase

" [VIEW]
syntax on


" machen, dass der befehl wie z.B. " a p  fuer register a
set showcmd
set number

set guioptions+=m  "show menu bar
set guioptions-=T  "remove toolbar
set guioptions+=r  "show right-hand scroll bar
set guioptions-=c  "use console dialogs instead of popups
set guioptions+=a  "autoselect: copy&paste using middleclick
set guioptions+=e  "add tab pages
set guioptions+=p  "use gui pointer callback for x11 


" ohne den naechsten eintrag verschwindet die powerline manchmal...
set laststatus=2

" set width for indentation
"set tabstop=2
"set softtabstop=2
"set shiftwidth=2
" replace tabstop by space
"set expandtab

" same in short...
set ts=2 sts=2 sw=2 expandtab 


let $PAGER=''

"set <S-Up>=^[[1;2A <S-Down>=^[[1;2B <S-Right>=^[[1;2C <S-Left>=^[[1;2D
"set <F13>=^[[24~
"map <F13> <S-Down>
"nnoremap <F13> :test
"set <F13>=^[9;0011
" map <F13> <xF1>

" q: ist der befehlseditor, damit kann man befehle kopieren in den textblock"
" q/ ist die history fuer die letzten suchen
"
" au=auto command, vimenter=event, *=filetype, NERDTree=command
" au vimenter * NERDTree

"nnoremap <Tab> :tabnext
"nnoremap <S-Tab> :tabpreviews

"nnoremap <C-Tab> :bnext<CR>
"nnoremap <C-S-Tab> :bprevious<CR>

"nnoremap <C-Tab> <C-PageDown>
"nnoremap <C-S-Tab> <C-PageUp>
"
nnoremap <C-Tab> :tabnext<CR>
nnoremap <C-S-Tab> :tabprevious<CR>
" do not display full path as tabname
set guitablabel=%t

"nnoremap <C-Tab> :bnext<CR>
"nnoremap <C-S-Tab> :bprevious<CR>

"nnoremap <C-Space> :call s:LaunchCompletion()
"inoremap <C-space> <C-x><C-o><C-p>
nnoremap <C-space> <C-n><C-n><C-p>
"inoremap <C-Space> <C-x><C-o>
inoremap <C-Space> <C-n>
"inoremap <C-@> <C-Space>
" open omni completion menu closing previous if open and opening new menu without changing the text
"
" simulate CTRL+C
vnoremap <C-c> y
"vnoremap <C-x> d
"noremap <C-v> gP " interfers with VISUAL BLOCK mode

" activate visual mode in normal mode
"map <S-Up> V
":map <S-Down> V
" these are mapped in visual mode
"map <S-Up> k
"map <S-Down> j
" increase/decrease indent in visual mode by tab and shift-tab
vmap <Tab> >gv
vmap <S-Tab> <gv

" make arrow keys work in visual mode
vmap <Esc>OA k
vmap <Esc>OB j
vmap <Esc>OC l
vmap <Esc>OD h
" map shift-right to visually select and so on
nnoremap <C-Right> El
nnoremap <S-Right> vl
nnoremap <S-Left> vj
nnoremap <S-Up> vk
nnoremap <S-Down> vj

" quickfix list (lists errors and warnings)
" nnoremap <F5> :cw<CR>
nnoremap <F5> :call ToggleQuickfixList()<CR>


"nnoremap <Tab> :MBEbf<CR>
"nnoremap <S-Tab> :MBEbb<CR>
nnoremap <Tab> <C-w>w
nnoremap <S-Tab> <C-w>W


" nnoremap <C-w> :q<CR>
noremap! <C-s> <ESC>:w<CR>

"nnoremap <C-]> :PREVCOLOR<CR>
nnoremap <C-K> :NEXTCOLOR<CR>


nnoremap <Home> ^
vmap <Home> ^

nnoremap <End> $
vmap <End> $

nnoremap <Leader> \

" nnoremap <C-o> :NERDTreeToggle<CR>
nnoremap <C-o> :browse e<CR>
let NERDTreeShowHidden=1
let NERDTreeQuiToNopen=1
let NERDChristmasTree=1
let NERDTreeMinimalUI=1
let NERDTreeWinSize = 40
let NERDTreeMapToggleHidden='\h'

" --------------------------------------------------------------------
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
"let g:airline_theme = 'powerlineish'
"let g:airline_theme = 'tomorrow'
let g:airline_theme = 'light'
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"


let g:miniBufExplAutoStart = 1
"let g:miniBufExplVSplit = 20   " column width in chars
"let g:miniBufExplBRSplit = 1   " Put new window below
let g:miniBufExplShowBufNumbers = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplCycleArround = 1
  let g:miniBufExplMapWindowNavVim = 1
  let g:miniBufExplMapWindowNavArrows = 1
  let g:miniBufExplMapCTabSwitchBufs = 1
  let g:miniBufExplModSelTarget = 1
" MiniBufExpl Colors
hi MBENormal               guifg=fg guibg=bg
hi MBEChanged              guifg=red guibg=bg
hi MBEVisibleNormal        guifg=bg guibg=fg
hi MBEVisibleChanged       guifg=bg guibg=FG
hi MBEVisibleActiveNormal  guifg=bg guibg=fg
hi MBEVisibleActiveChanged guifg=bg guibg=fg


if v:version >= 700
  au BufLeave * let b:winview = winsaveview()
  au BufEnter * if(exists('b:winview')) | call winrestview(b:winview) | endif
endif

" function! PlaySound()
"  silent! exec '!play ~/.vim/support/tape.aiff &'
" endfunction
"autocmd CursorMovedI * call PlaySound()


set nocompatible
set modeline
set modelines=3
" vim: syntax=vim
"
"
"
" clang_autocomplete options


let g:clang_use_library=1
"let g:clang_library_path='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib'
let g:clang_auto_select=0
let g:clang_complete_auto=1 " automatically complete after ->, ., ::
let g:clang_periodic_quickfix=1
let g:clang_close_preview=1 " If equal to 1, the preview window will be close automatically after a completion
"let g:clang_snippets=1
"let g:clang_conceal_snippets=1
"let g:clang_snippets_engine='clang_complete'
"let g:clang_complete_macros=1
"let g:clang_complete_patterns=1
"let g:clang_close_preview=1

" Show clang errors in the quickfix window
"let g:clang_complete_copen = 1
"
"
let g:clang_user_options='|| exit 0'
let g:clang_sort_algo="alpha"



" muss am ende stehen, macht das INSERT nicht angezeigt wird. macht ja airline
" auch schon.
set noshowmode " hide --INSERT-- from command line (as its already shown in airline)
set cursorline " highlight currently selected line

set wildmenu " displays command options in status line / airline when pressing TAB
set wildmode=longest:full,full

set scrolloff=2 " always keep at least two lines visible (when seeking)

"noremap help vert help
cabbrev help tab help
"autocmd FileType help,* wincmd L

"autocmd BufNew * if winnr('$') == 1 | tab sball | endif
"autocmd BufReadPost * tab ball
map ,e :e <C-R>=expand("%:p:h") . "/" <CR> 

" If wanted, auto commenting can be disabled for all files with: 
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o

colorscheme maxvb6
if has("gui_running")
  "colorscheme Tomorrow-Night-Blue
  "colorscheme bclear
else
  " use 256 colors in Console mode if we think the terminal supports it 
  if &term =~? 'mlterm\|xterm\|screen' 
    set t_Co=256
  endif
    "set t_Co=256
    "set t_AB=^[[48;5;%dm
    "set t_AF=^[[38;5;%dm
    "set term=ansi
    "colorscheme ibmedit
    "colorscheme h80
    "colorscheme greyhouse
    "colorscheme tango-morning
    "colorscheme jhlight
    "colorscheme newspaper
    "colorscheme relaxedgreen
    let g:airline_theme = 'hybrid'
    "highlight LineNr ctermfg=grey ctermbg=black
endif


" ex command for toggling hex mode - define mapping if desired
command -bar Hexmode call ToggleHex()

" helper function to toggle hex mode
function ToggleHex()
  " hex mode should be considered a read-only operation
  " save values for modified and read-only for restoration later,
  " and clear the read-only flag for now
  let l:modified=&mod
  let l:oldreadonly=&readonly
  let &readonly=0
  let l:oldmodifiable=&modifiable
  let &modifiable=1
  if !exists("b:editHex") || !b:editHex
    " save old options
    let b:oldft=&ft
    let b:oldbin=&bin
    " set new options
    setlocal binary " make sure it overrides any textwidth, etc.
    let &ft="xxd"
    " set status
    let b:editHex=1
    " switch to hex editor
    %!xxd
  else
    " restore old options
    let &ft=b:oldft
    if !b:oldbin
      setlocal nobinary
    endif
    " set status
    let b:editHex=0
    " return to normal editing
    %!xxd -r
  endif
  " restore values for modified and read only state
  let &mod=l:modified
  let &readonly=l:oldreadonly
  let &modifiable=l:oldmodifiable
endfunction


" Show syntax highlighting groups for word under cursor
map <C-S-P> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
      \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
      \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>


" Append modeline after last line in buffer using \ml
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files. 
function! AppendModeline()
  let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
        \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
  let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
  call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>


" make vimdiff ignore white spaces
set diffopt+=iwhite
set diffopt+=filler
set diffexpr=""
set nocompatible


set diffopt+=iwhite


set guicursor=n-v-c:ver30-Cursor-blinkon500-blinkoff500
highlight Cursor guifg=black guibg=lightgreen



set virtualedit=onemore
" damit das highlight der klammern nicht genauso aussieht wie der cursor
hi MatchParen cterm=none ctermbg=yellow ctermfg=yellow


" An example for a vimrc file.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2014 Nov 05
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

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

" Use Vim settings, rather than 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

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file (restore to previous version)
  set undofile		" keep an undo file (undo changes after closing)
endif
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

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

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

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
  set mouse=a
endif

" 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")
  syntax on
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  " Also don't do it when the mark is in the first line, that is the default
  " position when opening a file.
  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END

else

  set autoindent		" always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
		  \ | wincmd p | diffthis
endif

if has('langmap') && exists('+langnoremap')
  " Prevent that the langmap option applies to characters that result from a
  " mapping.  If unset (default), this may break plugins (but it's backward
  " compatible).
  set langnoremap
endif


































" An example for a vimrc file.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2014 Nov 05
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

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

" Use Vim settings, rather than 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

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file (restore to previous version)
  set undofile		" keep an undo file (undo changes after closing)
endif
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

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

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

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
  set mouse=a
endif

" 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")
  syntax on
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  " Also don't do it when the mark is in the first line, that is the default
  " position when opening a file.
  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END

else

  set autoindent		" always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
		  \ | wincmd p | diffthis
endif

if has('langmap') && exists('+langnoremap')
  " Prevent that the langmap option applies to characters that result from a
  " mapping.  If unset (default), this may break plugins (but it's backward
  " compatible).
  set langnoremap
endif