Skip to content

Instantly share code, notes, and snippets.

@oxyc
Created March 6, 2012 17:28
Show Gist options
  • Select an option

  • Save oxyc/1987622 to your computer and use it in GitHub Desktop.

Select an option

Save oxyc/1987622 to your computer and use it in GitHub Desktop.
set nocompatible " get out of vi-compatible mode
syntax on
scriptencoding utf-8
filetype plugin indent on
set autoindent
set smartindent
set backup " make backup files
set backupdir=~/.vim/backup " backup directory
set directory=~/.vim/swap " swap directory
set autochdir " switch to current file directory automatically
set backspace=indent,eol,start " make backspace more flexible
set hidden " change buffers without saving
set wildmenu " turn on cli completion wild style
set wildmode=list:longest " turn on wild mode huge list
set wildignore=*.jpg,*.png,.git " ignore these file extensions
set gdefault " Add the g flag to search/replace by default
set incsearch " highlight as you type your search
set hlsearch " highlight search
set ignorecase " case insensitive by default
set smartcase " if there are caps, go case-sensitive
set scrolloff=10 " keep 10 lines for scope
set showmatch " show matching brackets
" Backwards compability {
if version >= 703
set undodir=~/.vim/undo " undo directory
set undofile " store all undos
set undolevels=1000 " remember 1000 undos
set undoreload=10000 " save up to 10000 lines for undo on a buffer reload
endif
" }
" Folding {
set foldlevelstart=0
set foldmarker={,} " fold C style code
set foldmethod=marker " fold based on indent
set foldlevel=0 " don't autofold
set foldnestmax=10 " deepest fold is 10
set foldopen=block,hor,mark,percent,quickfix,tag " what movements open folds
" Space to toggle folds
nnoremap <space> zA
vnoremap <space> zA
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
nnoremap zO zCzO
" Use <leader>z to focus the current fold
nnoremap <leader>z zMzvzz
" }
au BufWinLeave * silent! mkview " make vim save view state,folds,cursor,etc
au BufWinEnter * silent! loadview " make vim load view state,folds,cursor,etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment