Meine *vimrc*

vimrc

" to reload the vimrc after editing without restarting vim type
"   :source $MYVIMRC

" lauch pathogen plugin manager
execute pathogen#infect()

let mapleader = ","
let maplocalleader = "-"

" configure external plugins
" Ctrl-P
nnoremap <leader>f :CtrlP<cr>
nnoremap <leader>b :CtrlPBuffer<cr>
let g:ctrlp_extensions = ['dir', 'line', 'bookmarkdir']
" NERDTree
nnoremap nt :NERDTreeToggle<CR>
let NERDTreeShowBookmarks=1

" quick saving
nnoremap <leader>w :w!<cr>

" maximize window in all directons, pipe needs escaping
nnoremap <C-w># <C-w>_<C-w>\|
nnoremap <leader># <C-w>_<C-w>\|
nnoremap <leader>= <C-w>=

" Breaks 'J' ... combine lines
"nnoremap H  ^
"nnoremap L  $
"nnoremap J  H
"nnoremap K  L

" two column mode
" URL: http://vim.wikia.com/wiki/View_text_file_in_two_columns
noremap <silent> <Leader>vs :<C-u>let @z=&so<CR>:set so=0 noscb<CR>:bo vs<CR>Ljzt:setl scb<CR><C-w>p:setl scb<CR>:let &so=@z<CR>

" Enable filetype plugin
filetype on
filetype indent on
filetype plugin on

" Filetypes and encoding
set fileformats=unix,dos,mac
set encoding=utf-8 fileencoding=utf-8 termencoding=utf-8
set wildignore+=.svn,CVS,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif

" diverse
set nocompatible                               " ViM settings instead of Vi
set nobackup nowritebackup noswapfile autoread " no backup or swap

" Coloring
syntax enable
colorscheme desert
set background=dark
set t_Co=256 " 256 colors in terminal
set cursorline
set cursorcolumn

if exists('+colorcolumn')
    :highlight ColorColumn ctermbg=235 guibg=#2c2d27
    set colorcolumn=80,120
    "let &colorcolumn="80,".join(range(120,500),",")
    "au FileType * let &colorcolumn="80,".join(range(120,500),",")
    "au FileType sql let &colorcolumn=join(range(75,500),",")
endif

if has ('clipboard')
    set clipboard=unnamed " use the system clipboard for yank/put/delete
    " necessary for Vi Improved Touch (Android)
    if has('X11')
        set clipboard+=unnamedplus
    endif
endif

set antialias   " Pretty fonts
set t_Co=256    " 256-color palletes
set linespace=0 " Don't insert any extra pixel lines
set lazyredraw  " Don't redraw while running macros

" Search options
set hlsearch
set incsearch
set ignorecase
set showmatch
set smartcase
set history=500
set tw=1000
" clean search highlighting (until again invoking a search command)
"nnoremap <esc> :noh<cr>

" make backspace a more flexible
" backspace over linebreaks
set backspace=indent,eol,start

" Disable sounds
set vb t_vb="
set noerrorbells
set visualbell

" indenting
set autoindent
set smartindent
set shiftwidth=4
set softtabstop=4
set tabstop=4
set smarttab
set expandtab

" status line etc.
set ruler
set laststatus=2
" add [encoding] to status bar
set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
"set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
"              | | | | |  |   |      |  |     |    |
"              | | | | |  |   |      |  |     |    + current
"              | | | | |  |   |      |  |     |       column
"              | | | | |  |   |      |  |     +-- current line
"              | | | | |  |   |      |  +-- current % into file
"              | | | | |  |   |      +-- current syntax in
"              | | | | |  |   |          square brackets
"              | | | | |  |   +-- current fileformat
"              | | | | |  +-- number of lines
"              | | | | +-- preview flag in square brackets
"              | | | +-- help flag in square brackets
"              | | +-- readonly flag in square brackets
"              | +-- rodified flag in square brackets
"              +-- full path to file in the buffer

set showmode
set showcmd
set number
set relativenumber

set switchbuf=useopen,usetab,newtab
" switch buffer without saving
set hidden

" folding
set foldmethod=indent
set nofoldenable

set scrolloff=3
set sidescroll=5

" Screen Size
" This is console Vim.
if exists("+lines")
  set lines=50
endif
if exists("+columns")
  set columns=100
endif

" make certain white spaces visible
set list
set list listchars=nbsp:¬,precedes:<,extends:>,tab:>-,trail:.,eol:$

" inverse moving by display/actual line
nnoremap k gk
nnoremap j gj
nnoremap gk k
nnoremap gj j

" Tabs - short keys
" manage
nnoremap tn  :tabnew<CR>
nnoremap td  :tabclose<CR>
" move
nnoremap th  :tabfirst<CR>
nnoremap tj  :tabnext<CR>
nnoremap tk  :tabprev<CR>
nnoremap tl  :tablast<CR>

" Windows - short keys
" create new windows right/below
set splitright
set splitbelow
" move
nnoremap wh  <C-w>h
nnoremap wj  <C-w>j
nnoremap wk  <C-w>k
nnoremap wl  <C-w>l

" Session management
" - do not store 'options' as this would overrule vimrc
"set sessionoptions=buffers,curdir,folds,help,localoptions,tabpages
set sessionoptions-=options
nnoremap ss :mksession! ~/default.vimsession<cr>
nnoremap ls :source ~/default.vimsession<cr>
" automatic session store/reload ... currently disabled
"autocmd VimLeave * execute ':mksession! ~/default.vimsession'
"autocmd VimEnter * execute ':source ~/default.vimsession'

" HEX mode
" http://vim.wikia.com/wiki/Improved_hex_editing
" ex command for toggling hex mode
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

"""""""""""""""""""
" Custom commands "
"""""""""""""""""""
" Pretty print json (requires python support)
command PPjson %! python -m json.tool

gvimrc

" to reload the gvimrc after editing without restarting vim type
"   :source $MYGVIMRC

" windows specific
" http://mkrmr.wordpress.com/2010/05/30/vim-tip-platform-specific-settings-in-your-vimrc/
if has('win16') || has('win32') || has('win64') || has('win95')
    set guifont=Consolas:h10    " looks good in windows (7), bad in linux (ubuntu 14.04/gnome3)
    set guifontwide=MingLiU:h10 " for windows to display mixed character sets
    set fileformats=dos,unix,mac
    " http://vim.wikia.com/wiki/Maximize_or_set_initial_window_size
    au GUIEnter * simalt ~x     " Maximize gvim window (<windows>+<up> keys)
endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Screen Size                                                                 "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maximize gvim window.
" set lines=999 columns=999
set guioptions +=c " Console messages in gVIM
set guioptions -=m " disable menu
set guioptions -=T " disable toolbar
set guioptions -=r " disable right scrollbar