Skip to content

Instantly share code, notes, and snippets.

@thejmazz
Last active March 1, 2016 03:53
Show Gist options
  • Save thejmazz/6618ded4dae5e02ea836 to your computer and use it in GitHub Desktop.
Save thejmazz/6618ded4dae5e02ea836 to your computer and use it in GitHub Desktop.
My .vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Vundle, the plug-in manager for Vim
Plugin 'gmarik/Vundle.vim'
" addon-mw-utils: interpret a file by function and cache file automatically
Plugin 'marcweber/vim-addon-mw-utils'
" tlib: some utility functions for VIM
Plugin 'tomtom/tlib_vim'
" nerdtree: a tree explorer plugin for vim
Plugin 'scrooloose/nerdtree'
" nerdtree-tabs: NERDTree and tabs together in Vim, painlessly
Plugin 'jistr/vim-nerdtree-tabs'
" fugitive: a Git wrapper so awesome, it should be illegal
Plugin 'tpope/vim-fugitive'
" airline: lean & mean status/tabline for vim that's light as air
Plugin 'bling/vim-airline'
" snipmate: support for textual snippets
Plugin 'garbas/vim-snipmate'
" snippets: vim-snipmate default snippets
Plugin 'honza/vim-snippets'
" emmet: emmet for vim
Plugin 'mattn/emmet-vim'
" autoformat: provide easy code formatting in Vim by integrating existing code formatters
Plugin 'Chiel92/vim-autoformat'
" javascript-syntax: enhanced javascript syntax for Vim
Plugin 'jelera/vim-javascript-syntax'
" surround: quoting/parenthesizing made simple
Plugin 'tpope/vim-surround'
" repeat.vim: enable repeating supported plugin maps
Plugin 'tpope/vim-repeat'
" auto-pairs: insert or delete brackets, parens, quotes in pair
Plugin 'jiangmiao/auto-pairs'
" misc: miscellaneous auto-load Vim scripts
Plugin 'xolox/vim-misc'
" session: extended session manegement for Vim (:mksession on steroids)
Plugin 'xolox/vim-session'
" go: Go developoment plugin for Vim
Plugin 'fatih/vim-go'
" jshint.vim: a plugin that integrates JSHint with Vim
Plugin 'walm/jshint.vim'
" tabular: Vim script for text filtering and alignment
Plugin 'godlygeek/tabular'
" VIM Table Mode for instant table creation
Plugin 'dhruvasagar/vim-table-mode'
" Markdown Vim Mode
Plugin 'plasticboy/vim-markdown'
" tcomment: an extensible and universal comment vim-plugin that also handles embedded filetypes
Plugin 'tomtom/tcomment_vim'
" one colorscheme pack to rule them all!
Plugin 'flazz/vim-colorschemes'
" CoffeeScript support for vim
Plugin 'kchmck/vim-coffee-script'
" base-16-vim colour scheme
Plugin 'chriskempson/base16-vim'
" A code-completion engine for Vim
Plugin 'Valloric/YouCompleteMe'
" A Vim plugin which shows a git diff in the gutter (sign column) and stages/reverts hunks
Plugin 'airblade/vim-gitgutter'
" Plugin to work with R
Plugin 'vim-scripts/Vim-R-plugin'
call vundle#end()
filetype plugin indent on
" Vundle commands
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
syntax on
syntax enable
" Mappings
map <S-Right> :tabn<CR>
map <S-Left> :tabp<CR>
map <C-n> :tabnew<CR>
map <F2> :NERDTreeTabsToggle<CR>
nnoremap <silent><F3> :call g:ToggleColorColumn()<CR>
map <F7> :setlocal spell! spelllang=en_ca<CR>
map <F12> :SaveSession<CR>
map <F10> :JSHint<CR>
map <C-n><C-n> :set invnumber<CR>
" Easier split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Change split sizes
map <C-u> :resize +1 <CR>
map <C-i> :resize -1 <CR>
map <C-p> :resize +9001 <CR>
" Use ctrl-[up|down] to scroll w/o moving cursor
map <C-Down> <C-E>
map <C-Up> <C-Y>
" For better LaTeX formatting
omap lp ?^$\\|^\s*\(\\begin\\|\\end\\|\\label\\|\\item\)?1<CR>//-1<CR>.<CR>
" Autocomplete {
"inoremap {<CR> {<CR>}<Esc>ko
"inoremap ( ()<Esc>ko
" Visual Mode mappings
vmap gb :TCommentBlock<CR>
" Automatic commands on startup
au BufRead * normal zR
autocmd BufNewFile,BufRead *.md set filetype=markdown
:command OS OpenSession
" No line wrapping
set nowrap
" Always show 10 lines above/below
set scrolloff=10
" Setup for vim-airline
let g:airline_powerline_fonts=1
let g:airline_left_sep=''
let g:airline_right_sep=''
"let g:airline_theme='twilight' "This is lost forever now :(
" Favorite themes:
" tomorrow: nice, minimal
" luna: nice, colourful
" murmur: needs main bar colour
" bubblegum: simple, minimal
" durant: nice insert, purple main on edit though
" hybrid: nice normal
" hybridline: nice insert
let g:airline_theme='durant'
" The ultimate theme would be:
" tomorrow modified to be
" normal: hybrid
" visual: self
" insert: hybridline
let g:airline#extensions#whitespace#enabled=0
" vim-session settings
:let g:session_autosave = 'no'
" vim-go settings
let g:go_fmt_autosave = 0
" Enhanced JS syntax
au FileType javascript call JavaScriptFold()
" Markdown table settings for table-mode
let g:table_mode_corner="|"
" Enable 256 Colours
"set t_Co=256
" Default colorscheme
"colorscheme twilight
"colorscheme hybridbrackets
" set background=light
" colorscheme solarized
set t_Co=256
"set background=dark
"colorscheme monokai
colorscheme Kafka
set background=dark
"colorscheme oceandeep
"let base16colorspace=256 " Access colors present in 256 colorspace"
"colorscheme base16-ocean
" highlight Normal ctermbg=NONE
" highlight nonText ctermbg=NONE
" Line number colours
"highlight LineNr ctermfg=170 ctermbg=232
"highlight Comment ctermfg=145
" Color column
"highlight ColorColumn ctermbg=111
" Show statusline
set laststatus=2
" Enable mouse scrolling
set mouse=nicr
" Set up tabs
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
au FileType javascript setl sw=2 sts=2 et
au FileType yaml setl sw=2 sts=2 et
" Show line numbers
set number
" Text width at 80 characters
set textwidth=80
" Turn off automatic text wrapping
set formatoptions-=t
"Above may not work, fo overwritten somewhere else, so:
autocmd BufNewFile,BufRead * setlocal formatoptions-=t
" Enable soft-wrap
"set wrap linebreak nolist
" Highlight text past 80 characters
"augroup vimrc_autocmds
" autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
" autocmd BufEnter * match OverLength /\%81v.*/
"augroup END
" ==== Commands ====
command GetWidth echom LongestLineLength()
command Vsp call VSplitAutoResize()
command Sp call SplitAutoResize()
" ==== Functions ====
function AutoformatAndSave()
:Autoformat
:wq
endfunction
" Toggles colorcolumn at textwidth+1
function! g:ToggleColorColumn()
if &colorcolumn != ''
setlocal colorcolumn&
else
setlocal colorcolumn=+1
endif
endfunction
function! SplitAutoResize()
exe ":sp"
exe ':resize ' . line('$')
endfunction
function! VSplitAutoResize()
exe ":vsp"
exe ':vertical resize ' . LongestLineLength()
" Wrap when files wider than 90
if LongestLineLength() > 90
exe ":set wrap"
endif
exe ":0"
endfunction
" Returns width of longest line
" Modified from http://stackoverflow.com/a/2075372/1409233
function! LongestLineLength ( )
let maxlength = 0
let linenumber = 1
let longestline = 0
while linenumber <= line("$")
exe ":".linenumber
let linelength = virtcol("$")
if maxlength < linelength
let maxlength = linelength
let longestline = linenumber
endif
let linenumber = linenumber+1
endwhile
if maxlength > 90
let maxlength = 90
endif
" Add 3 for line numbers
return maxlength + 3
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment