Skip to content

Instantly share code, notes, and snippets.

@trkoch
Last active December 15, 2015 15:28
Show Gist options
  • Save trkoch/5281542 to your computer and use it in GitHub Desktop.
Save trkoch/5281542 to your computer and use it in GitHub Desktop.
Basic vim config: curl -L http://git.io/kochvim > .vimrc
" Basic
syntax on
set nocompatible
set encoding=utf-8
set vb
" Buffers and windows
set hidden
set autoread
set shortmess+=IA
set splitright
set splitbelow
" Indendation, whitespaces and wrapping
set autoindent
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set backspace=indent,eol,start
set nowrap
set linebreak
" Backup, swap and undo files
set undofile
set backupdir=~/.vim/tmp,.
set directory=~/.vim/tmp,.
set undodir=~/.vim/tmp,.
" Create tmp/ directory if not existing
if isdirectory($HOME . '/.vim/tmp') == 0
:silent !mkdir -p ~/.vim/tmp >/dev/null 2>&1
endif
" Search
set nohlsearch
set ignorecase
set smartcase
set incsearch
" Better comand-line completion
set wildmenu
" Relax, a mouse can come in handy
" set mouse=a
" Sessions
set sessionoptions-=options
" Ignores
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
set wildignore+=*.swp,*~,._*
" Strong encryption
set cryptmethod=blowfish
" j/k moves visually
nnoremap j gj
nnoremap k gk
" Visual shifting
vnoremap < <gv
vnoremap > >gv
" Automatically resize splits when resizing window
autocmd VimResized * wincmd =
" Toggle cursor line
nnoremap <leader>cl :set invcursorline<cr>
" Toggle hlsearch with <leader>hs
nmap <leader>hs :set hlsearch! hlsearch?<cr>
" Jump to EOL/BOL in insert mode, emacs style
inoremap <c-a> <c-o>I
inoremap <c-e> <c-o>A
" Cycle buffers with tab
nmap <silent> <tab> :b#<cr>
" Navigate windows
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
" Scrolling
set scrolloff=1
nmap <c-u> 6<c-y>
nmap <c-d> 6<c-e>
" Keep position of cursor while yanking
" vmap y ygv<esc>
" Copy previous selection to unnamed register
xnoremap p pgvy
" Select last changed (or pasted)
" nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
" Some default keybindings are akward with a german keyboard layout.
" Provide alternatives, mostly using keys not found on a US keyboard.
nmap ö {
vmap ö {
nmap Ö (
vmap Ö (
nmap ä }
vmap ä }
nmap Ä )
vmap Ä )
nmap ü ]
vmap ü ]
nmap Ü [
vmap Ü [
nnoremap <s-cr> -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment