Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Last active March 3, 2016 09:12
Show Gist options
  • Save icyleaf/7925230 to your computer and use it in GitHub Desktop.
Save icyleaf/7925230 to your computer and use it in GitHub Desktop.
vim config (Mac OS + vim + vundle)
" Vim Config
" Source: http://www.integralist.co.uk/posts/vim-workflow-part-deux/
" switch syntax highlighting on, when the terminal has colors
syntax on
" use vim, not vi api
set nocompatible
" no backup files
set nobackup
" no write backup
set nowritebackup
" no swap file
set noswapfile
" command history
set history=100
" always show cursor
set ruler
" show incomplete commands
set showcmd
" incremental searching
set incsearch
" highlight search
set hlsearch
" ignore case in search
set smartcase
" make sure any searches /searchPhrase doesn't need the \c escape character
set ignorecase
" a buffer is marked as ‘hidden’ if it has unsaved changes, and it is not currently loaded in a window
" if you try and quit Vim while there are hidden buffers, you will raise an error:
" E162: No write since last change for buffer “a.txt”
set hidden
" disable folding because it is evil
set nofoldenable
" turn word wrap off
set nowrap
" scroll with more context
set scrolloff=10
" allow backspace to delete end of line, indent and start of line characters
set backspace=indent,eol,start
" convert tabs to spaces
set expandtab
" set tab size
set tabstop=4
" the number of spaces inserted for a tab
set shiftwidth=4
" turn on line numbers
set number
" highlight tailing whitespace
set list listchars=tab:\ \ ,trail:·
" get rid of the delay when pressing O (for example)
" http://stackoverflow.com/questions/2158516/vim-delay-before-o-opens-a-new-line
set timeout timeoutlen=1000 ttimeoutlen=100
" always show status bar
set laststatus=2
" set the status line to something useful
set statusline=%f\ %=L:%l/%L\ %c\ (%p%%)
" hide the toolbar
set guioptions-=T
" utf encoding
set encoding=utf-8
" autoload files that have changed outside of vim
set autoread
" use system clipboard
" http://stackoverflow.com/questions/8134647/copy-and-paste-in-vim-via-keyboard-between-different-mac-terminals
set clipboard+=unnamed
" don't show intro
set shortmess+=I
" better splits
set splitbelow
set splitright
" turn indentation on
filetype indent on
" enable filetype plugins
filetype plugin on
" jump to last cursor
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
fun! StripTrailingWhitespace()
" don't strip on these filetypes
if &ft =~ 'markdown'
return
endif
%s/\s\+$//e
endfun
autocmd BufWritePre * call StripTrailingWhitespace()
" file formats
autocmd Filetype gitcommit setlocal spell textwidth=72
autocmd Filetype markdown setlocal textwidth=80
autocmd FileType cucumber,ruby,yaml setl sw=2 sts=2 et
" specify syntax highlighting for specific files
au Bufread,BufNewFile *.spv set filetype=php
au Bufread,BufNewFile *.md set filetype=markdown
"'modula2' otherwise, see :set filetype?
" Declare bundles are handled via Vundle
set rtp+=$HOME/.vim/bundle/vundle
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" CtrlP
Bundle 'kien/ctrlp.vim'
map <leader>t <C-p>
map <leader>y :CtrlPBuffer<cr>
let g:ctrlp_show_hidden=1
let g:ctrlp_working_path_mode=0
let g:ctrlp_max_height=30
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*.,*/.DS_Store
" Tomorrow Night Theme
Bundle 'jlangston/tomorrow-night-vim'
:silent! :colorscheme tomorrow-night-bright
" Markdown
Bundle 'tpope/vim-markdown'
" Markdown (allow piping of markdown files to the browser)
au BufEnter,BufNew *.md map <enter> :wa\|!rbfu rdiscount % \| bcat<cr>
" Cucumber
Bundle 'tpope/vim-cucumber'
" Tags
" First run `ctags -R` within the root directory (this is installed via Homebrew)
" Second within your file, on a method/class/object (whatever) press `Ctrl+]`
Bundle 'xolox/vim-misc'
Bundle 'majutsushi/tagbar'
let g:tagbar_ctags_bin='/usr/local/bin/ctags'
" Tags
" Open Tagbar when pressing <leader>b
" And automatically close it after selecting something
:map <leader>b :TagbarOpenAutoClose<cr>
" Tab completion
Bundle 'ervandew/supertab'
" Enable repeating supported plugin maps with '.'
Bundle 'tpope/vim-repeat'
" Comment out stuff
Bundle 'tpope/vim-commentary.git'
" Ack (uses Ag behind the scenes)
Bundle 'mileszs/ack.vim'
let g:ackprg = 'ag --nogroup --nocolor --column'
" Applies `end` keyword to relevant lines of ruby code
Bundle 'tpope/vim-endwise'
" Status line design improvements
Bundle 'Lokaltog/powerline'
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
" Gists
Bundle 'mattn/webapi-vim'
Bundle 'vim-scripts/Gist.vim'
Bundle 'tpope/vim-fugitive'
" Gists (Github settings)
let g:github_user = $GITHUB_USER
let g:github_token = $GITHUB_TOKEN
" HTML generation (in NORMAL mode Ctrl+y then , <C-y,>)
Bundle 'mattn/emmet-vim'
" Rename variables and files in your code
Bundle 'vim-scripts/rename.vim'
" tmux switcher
" http://robots.thoughtbot.com/post/53022241323/seamlessly-navigate-vim-and-tmux-splits
Bundle 'christoomey/vim-tmux-navigator'
" Git gutter
Bundle 'airblade/vim-gitgutter'
let g:gitgutter_enabled = 1
let g:gitgutter_eager = 0
let g:gitgutter_sign_column_always = 1
highlight clear SignColumn
" File System
Bundle 'vim-scripts/The-NERD-tree'
map <leader>' :NERDTreeToggle<cr>
" Snippets
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
Bundle 'garbas/vim-snipmate'
" SCSS, Sass & Haml Syntax Support
Bundle 'tpope/vim-haml'
" Surround text with HTML or punctuation
Bundle 'tpope/vim-surround'
" HTML5 syntax
Bundle 'othree/html5.vim'
" Tabularize
Bundle 'godlygeek/tabular'
map <Leader>e :Tabularize /=<cr>
map <Leader>c :Tabularize /:<cr>
" JS Hint
Bundle 'Shutnik/jshint2.vim'
@icyleaf
Copy link
Author

icyleaf commented Dec 12, 2013

Install

  1. install vundle
  2. Download .vimrc to ~/.vimrc
  3. vim +BundleInstall +qall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment