Skip to content

Instantly share code, notes, and snippets.

@jeffsharpe
Last active August 29, 2015 14:05
Show Gist options
  • Save jeffsharpe/38cf9e5430134fa8d70c to your computer and use it in GitHub Desktop.
Save jeffsharpe/38cf9e5430134fa8d70c to your computer and use it in GitHub Desktop.
vimrc - 20150605
""
""
"" Mappings / Keybindings
""
"" leader is ','
""
"" Manipulate $MYVIMRC
"" Use <leader>ev to edit .vimrc
"" Use <leader>sv to reload .vimrc
""
"" Formatting
"" Use <leader>fef to format entire file
"" Use <leader>ul to underline the current line with '='
"" Use <leader>cw to format CAF files
""
"" Case changing
"" Use <leader>u to upcase word
"" Use <leader>l to lowercase word
"" Use <leader>U to upcase first character of word
"" Use <leader>L to lowercase first character of word
""
"" Managing tabs / windows
"" Use <leader>tn to create new tab
"" Use <leader>tc to close tab
"" Use jk to exit insert mode
""
"" Searching
"" Use ss to search for next misspelled word
"" Use <leader>s to build regexp from word under cursor
""
"" Extra stuff
"" Use <leader>n to toggle NERDTreeToggle
"" Use <F8> to toggle Tagbar
"" Use <F5> to toggle Gundo
"" Use <ctl>p to do a fuzzy find
""
"" Basic Setup
""
set nocompatible " Use vim, no vi defaults
set number " Show line numbers
set ruler " Show line and column number
syntax enable " Turn on syntax highlighting
set modeline " Use modelines
" Auto reload vimrc
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }
" Auto load a file when changed externally
set autoread
""
"" Whitespace
""
set nowrap " Don't wrap lines
set tabstop=2 " A tab is 2 spaces
set shiftwidth=2 " An autoident (with <<) is 2 spaces
set expandtab " Use spaces, not tabs
set backspace=indent,eol,start " Backspace through everything in insert mode
""
"" Searching
""
set hlsearch " Highlight matches
set incsearch " Incremental searching
set ignorecase " Searches are case insensitive
set smartcase " ... unless they contain at least one capital letter
""
"" Backup and swap files
""
set nowritebackup " Do not write a backup before replacing file
set noswapfile " Do not create a swapfile
set nobackup " Do not make a backup file
"
" Status line (using lightline instead)
"
if has("statusline") && !&cp
set laststatus=2 " always show the status bar
" Start the status line
set statusline=%f\ %m\ %r\ %h
set statusline+=Line:%l/%L[%p%%]
set statusline+=Col:%v
set statusline+=Buf:#%n
set statusline+=[%b][0x%B]
endif
"
" Misc settings
"
set spelllang=en_ca
set encoding=utf-8 " Set default encoding
set cursorline
set clipboard=unnamed
set synmaxcol=128
set ttyscroll=10
set scrolloff=5
set ffs=unix,dos,mac
set ff=unix " convert dos line endings
"
" NERDTree
"
let NERDTreeWinPos="left"
let NERDTreeAutoDeleteBuffer=1
"
" vim-session
"
" autosave opened sessions
let g:session_autosave='no'
" only save the current tab page
set sessionoptions-=tabpages
" will prompt for a session if vim started without a file
let g:session_autoload='yes'
" do not add colour schemes to session
let g:session_persist_colors=0
"
" MiniBufExpl
"
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
"
" CtrlP
"
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
"
" Gundo
"
let g:gundo_width = 60
let g:gundo_preview_height = 40
let g:gundo_right = 1
"
" Bundles
"
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" Bundles
Bundle 'tpope/vim-fugitive'
Bundle 'scrooloose/syntastic'
Bundle 'majutsushi/tagbar'
Bundle 'scrooloose/nerdtree'
Bundle 'kien/ctrlp.vim'
Bundle 'tpope/vim-eunuch'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-bundler'
Bundle 'tpope/vim-haml.git'
Bundle 'pangloss/vim-javascript.git'
Bundle 'tpope/vim-cucumber.git'
Bundle 'tpope/vim-markdown.git'
Bundle 'ajf/puppet-vim.git'
Bundle 'kchmck/vim-coffee-script.git'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-git.git'
Bundle 'timcharper/textile.vim.git'
Bundle 'skwp/vim-rspec.git'
Bundle 'cakebaker/scss-syntax.vim.git'
Bundle 'chrisbra/csv.vim.git'
Bundle 'mmalecki/vim-node.js.git'
Bundle 'vim-ruby/vim-ruby.git'
Bundle 'groenewege/vim-less.git'
Bundle 'ap/vim-css-color'
Bundle 'tpope/vim-rake'
Bundle 'mattn/gist-vim'
Bundle 'rodjek/vim-puppet'
Bundle 'itchyny/lightline.vim'
Bundle 'MarcWeber/vim-addon-mw-utils.git'
Bundle 'tomtom/tlib_vim'
Bundle 'vim-scripts/TailMinusF'
Bundle 'xolox/vim-session'
Bundle 'xolox/vim-misc'
Bundle 'fholgado/minibufexpl.vim'
Bundle 'sjl/gundo.vim'
Bundle 'nvie/vim-flake8'
Bundle 'klen/python-mode'
Bundle 'ludovicchabant/vim-gutentags'
" Color Bundles
Bundle 'altercation/vim-colors-solarized.git'
Bundle 'vim-scripts/molokai.git'
Bundle 'telamon/vim-color-github.git'
Bundle 'nanotech/jellybeans.vim'
" No show command
autocmd VimEnter * set nosc
"
" Custom Mappings / Keybindings
"
" Set the leader
let mapleader=","
" Manipulate $MYVIMRC
" Open your vimrc for editing
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" Reload your vimrc
nnoremap <leader>sv :source $MYVIMRC<cr>
" Formatting
" Format the entire file
nmap <leader>fef ggVG=
" Underline the current line with '='
nmap <silent> <leader>ul :t.<CR>Vr=
" Some CAF mappings
nnoremap <leader>cw :6<cr> VG50<gvgqgg :echom "CAF wrapped"<cr>
" Case changing
" upper/lower word
nmap <leader>u mQviwU`Q
nmap <leader>l mQviwu`Q"
" upper/lower first char of word
nmap <leader>U mQgewvU`Q
nmap <leader>L mQgewvu`Q
" Managing tabs / windows
" Mappings to manage tabs
map <leader>tn :tabnew<cr>
map <leader>tc :tabclose<cr>
" Exit insert mode to save finger typing
inoremap jk <esc>
" Searching
"" Search for next misspelled word and make suggestion
nnoremap ss ]sz=
" Build a regexp from word under cursor
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" Extra stuff
" Use NERDTree
map <leader>n :NERDTreeToggle<CR>
" Toggle Tagbar
map <F8> :TagbarToggle<CR>
" Toggle Gundo
nnoremap <F5> :GundoToggle<CR>
"
" Theme
"
" color inkpot
color jellybeans
"
" Filetypes
"
filetype plugin indent on
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make setlocal noexpandtab
" Set the Ruby filetype for a number of common Ruby files without .rb
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,Procfile,Guardfile,config.ru,*.rake} set ft=ruby
" Make sure all markdown files have the correct filetype set
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown
" Automatic formatting
autocmd BufWritePre *.rb :%s/\s\+$//e
autocmd BufWritePre *.go :%s/\s\+$//e
autocmd BufWritePre *.haml :%s/\s\+$//e
autocmd BufWritePre *.html :%s/\s\+$//e
autocmd BufWritePre *.scss :%s/\s\+$//e
autocmd BufWritePre *.slim :%s/\s\+$//e
"***Language specified***
" shell (tab width 2 chr)
autocmd FileType sh set sw=2
autocmd FileType sh set ts=2
autocmd FileType sh set sts=2
autocmd FileType sh map <buffer> <C-S-e> :w<CR>:!/bin/sh % <CR>
" ruby (tab width 2 chr)
autocmd FileType ruby set sw=2
autocmd FileType ruby set ts=2
autocmd FileType ruby set sts=2
autocmd FileType ruby map <buffer> <C-S-e> :w<CR>:!/usr/bin/env ruby % <CR>
" HTML (tab width 2 chr, no wrapping)
autocmd FileType html set sw=2
autocmd FileType html set ts=2
autocmd FileType html set sts=2
autocmd FileType html set textwidth=0
" Python (tab width 4 chr)
autocmd FileType python set sw=4
autocmd FileType python set ts=4
autocmd FileType python set sts=4
autocmd FileType python map <buffer> <C-S-e> :w<CR>:!/usr/bin/env python % <CR>
" CSS (tab width 2 chr)
autocmd FileType css set sw=2
autocmd FileType css set ts=2
autocmd FileType css set sts=2
" JavaScript (tab width 4 chr)
autocmd FileType javascript set sw=4
autocmd FileType javascript set ts=4
autocmd FileType javascript set sts=4
autocmd FileType javascript map <buffer> <C-S-e> :w<CR>:!/usr/bin/env node % <CR>
" Php (tab width 2 chr)
autocmd FileType php set sw=2
autocmd FileType php set ts=2
autocmd FileType php set sts=2
" Cucumber (tab width 2 chr)
autocmd FileType Cucumber set sw=2
autocmd FileType Cucumber set ts=2
autocmd FileType Cucumber set sts=2
au BufNewFile * set noeol
au BufRead,BufNewFile *.go set filetype=go
" Turn on spell checking for Git commits
autocmd FileType gitcommit setlocal spell
" Run Flake8 every time you edit a Python file
autocmd BufWritePost *.py call Flake8()
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Ignore rails temporary asset caches
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/*
" Disable temp and backup files
set wildignore+=*.swp,*~,._*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment