Created
June 17, 2015 13:34
-
-
Save terakilobyte/54b2b3429b1d52c3ac8c to your computer and use it in GitHub Desktop.
vim settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if &compatible | |
set nocompatible | |
end | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#rc() | |
" Let Vundle manage Vundle | |
Plugin 'gmarik/Vundle.vim' | |
" Define bundles via Github repos | |
Plugin 'fatih/vim-go' | |
Plugin 'rust-lang/rust.vim' | |
Plugin 'JulesWang/css.vim' | |
Plugin 'moll/vim-node' | |
Plugin 'christoomey/vim-run-interactive' | |
Plugin 'danro/rename.vim' | |
Plugin 'kchmck/vim-coffee-script' | |
Plugin 'kien/ctrlp.vim' | |
Plugin 'pbrisbin/vim-mkdir' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'scrooloose/nerdtree' | |
Plugin 'scrooloose/nerdcommenter' | |
Plugin 'slim-template/vim-slim' | |
Plugin 'tpope/vim-endwise' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'tpope/vim-surround' | |
Plugin 'tpope/vim-sensible' | |
Plugin 'vim-scripts/matchit.zip' | |
Plugin 'vim-scripts/ctags.vim' | |
Plugin 'flazz/vim-colorschemes' | |
Plugin 'vim-scripts/tComment' | |
Plugin 'bling/vim-airline' | |
Plugin 'mattn/emmet-vim' | |
Plugin 'jelera/vim-javascript-syntax' | |
Plugin 'pangloss/vim-javascript' | |
Plugin 'mxw/vim-jsx' | |
Plugin 'nathanaelkane/vim-indent-guides' | |
Plugin 'Raimondi/delimitMate' | |
Plugin 'Valloric/YouCompleteMe' | |
Plugin 'marijnh/tern_for_vim' | |
Plugin 'brndnb/vim-colors-solarized' | |
Plugin 'christoomey/vim-tmux-navigator' | |
Plugin 'bitc/vim-hdevtools.git' | |
Plugin 'dag/vim2hs' | |
Plugin 'jpalardy/vim-slime.git' | |
Plugin 'SirVer/ultisnips' | |
Plugin 'honza/vim-snippets' | |
Plugin 'justinj/vim-react-snippets' | |
Plugin 'majutsushi/tagbar' | |
Plugin 'tpope/vim-unimpaired' | |
Plugin 'godlygeek/tabular' | |
Plugin 'digitaltoad/vim-jade' | |
Plugin 'mustache/vim-mustache-handlebars' | |
Plugin 'tpope/vim-commentary' | |
Plugin 'terryma/vim-multiple-cursors' | |
Plugin 'othree/html5.vim' | |
Plugin 'plasticboy/vim-markdown' | |
Plugin 'justinmk/vim-sneak' | |
Plugin 'mattn/webapi-vim' | |
Plugin 'mattn/gist-vim' | |
Plugin 'rizzatti/dash.vim' | |
Plugin 'groenewege/vim-less' | |
if filereadable(expand("~/.vimrc.bundles.local")) | |
source ~/.vimrc.bundles.local | |
endif | |
filetype on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use Vim settings, rather then Vi settings. This setting must be as early as | |
" possible, as it has side effects. | |
set nocompatible | |
" Leader | |
let mapleader = " " | |
set backspace=2 " Backspace deletes like most programs in insert mode | |
set nobackup | |
set nowritebackup | |
set noswapfile | |
set history=1000 | |
set undolevels=1000 | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
set laststatus=2 " Always display the status line | |
set autowrite " Automatically :write before running commands | |
set clipboard=unnamedplus,unnamed,autoselect,exclude:.* "Make yank copy to system clipboard | |
set shortmess +=I " hide VIM intro message | |
set timeoutlen=1000 ttimeoutlen=0 " eliminate delays on ESC | |
set foldlevelstart=20 | |
let g:go_fmt_command = "goimports" | |
imap <C-c> <CR><Esc>O | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") | |
syntax on | |
endif | |
if filereadable(expand("~/.vimrc.bundles")) | |
source ~/.vimrc.bundles | |
endif | |
filetype plugin indent on | |
augroup vimrcEx | |
autocmd! | |
" For all text files set 'textwidth' to 78 characters. | |
autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it for commit messages, when the position is invalid, or when | |
" inside an event handler (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
" Set syntax highlighting for specific file types | |
autocmd BufRead,BufNewFile Appraisals set filetype=ruby | |
autocmd BufRead,BufNewFile *.md set filetype=markdown | |
" Enable spellchecking for Markdown | |
autocmd FileType markdown setlocal spell | |
" Automatically wrap at 80 characters for Markdown | |
autocmd BufRead,BufNewFile *.md setlocal textwidth=80 | |
augroup END | |
" Softtabs, 2 spaces | |
set tabstop=2 | |
set shiftwidth=2 | |
set shiftround | |
set expandtab | |
" Use a leader instead of the actual named binding | |
nmap <leader>p :CtrlP<cr> | |
" Easy bindings for its various modes | |
nmap <leader>bb :CtrlPBuffer<cr> | |
nmap <leader>bm :CtrlPMixed<cr> | |
nmap <leader>bs :CtrlPMRU<cr> | |
" Display extra whitespace | |
set list listchars=tab:»·,trail:· | |
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher | |
if executable('ag') | |
" Use Ag over Grep | |
set grepprg=ag\ --nogroup\ --nocolor | |
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
" ag is fast enough that CtrlP doesn't need to cache | |
let g:ctrlp_use_caching = 0 | |
endif | |
" Color scheme | |
"colorscheme github | |
"highlight NonText guibg=#060606 | |
"highlight Folded guibg=#0A0A0A guifg=#9090D0 | |
" Numbers | |
" set number | |
set numberwidth=5 | |
" Tab completion | |
" will insert tab at beginning of line, | |
" will use completion if not at beginning | |
"set wildmode=list:longest,list:full | |
"function! InsertTabWrapper() | |
" let col = col('.') - 1 | |
" if !col || getline('.')[col - 1] !~ '\k' | |
" return "\<tab>" | |
" else | |
" return "\<c-p>" | |
" endif | |
"endfunction | |
"inoremap <Tab> <c-r>=InsertTabWrapper()<cr> | |
" Index ctags from any project | |
map <Leader>ct :!ctags -R .<CR> | |
" Switch between the last two files | |
nnoremap <leader><leader> <c-^> | |
" Get off my lawn | |
nnoremap <Left> :echoe "Use h"<CR> | |
nnoremap <Up> :echoe "Use k"<CR> | |
nnoremap <Down> :echoe "Use j"<CR> | |
nnoremap <Right> :echoe "use l"<CR> | |
" Run commands that require an interactive shell | |
nnoremap <Leader>r :RunInInteractiveShell<space> | |
" Treat <li> and <p> tags like the block tags they are | |
let g:html_indent_tags = 'li\|p' | |
" Open new split panes to right and bottom, which feels more natural | |
set splitbelow | |
set splitright | |
" Quicker window movement | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-l> <C-w>l | |
" Highlight all search matches | |
set hlsearch | |
set noincsearch | |
" NERDTree | |
let NERDTreeHighlightCursorline=1 | |
let NERDTreeIgnore=['tmp', '.yardoc', 'pkg'] | |
let javascript_enable_domhtmlcss=1 | |
" configure syntastic syntax checking to check on open as well as save | |
let g:syntastic_check_on_open=1 | |
let g:syntastic_html_tidy_ignore_errors=["plain text isn't allowed in <head> elements", " proprietary attribute \"ng-", "trimming empty <span>", "is not recognized!", "discarding unexpected"] | |
let g:syntastic_html_tidy_exec = '/usr/local/bin/tidy' | |
let g:syntastic_javascript="eslint" | |
let g:syntastic_javascript_checkers = ['eslint'] | |
" configure YouCompleteMe | |
let g:ycm_add_preview_to_completeopt=0 | |
let g:ycm_confirm_extra_conf=0 | |
set completeopt-=preview | |
" configure delimitMate | |
let g:delimitMate_expand_cr = 1 | |
let g:delimitMate_expand_space = 1 | |
" Trigger configuration. Do not use <tab> if you use YouCompleteMe. | |
let g:UltiSnipsExpandTrigger="<c-e>" | |
let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-z>"" | |
" Mustache Handlebars config | |
let g:mustache_abbreviations = 1 | |
let NERDTreeShowHidden=1 | |
" Auto open nerdtree | |
function! StartUp() | |
if 0 == argc() | |
NERDTree | |
end | |
endfunction | |
autocmd VimEnter * call StartUp() | |
" Set solarized light | |
syntax enable | |
let g:solarized_termcolors=256 | |
set background=light | |
colorscheme monokai | |
" Open bigger you bastard | |
if has("gui_running") | |
" GUI is running or is about to start. | |
" Maximize gvim window (for an alternative on Windows, see simalt below). | |
set lines=84 columns=118 | |
else | |
" This is console Vim. | |
if exists("+lines") | |
set lines=50 | |
endif | |
if exists("+columns") | |
set columns=100 | |
endif | |
endif | |
" Line Number | |
set nu | |
" Line Length | |
set colorcolumn=80 | |
" Vim Slime | |
let g:slime_target = "tmux" | |
let g:slime_paste_file = tempname() | |
" Vim Sneak | |
let g:sneak#streak = 1 | |
" Local config | |
if filereadable($HOME . "/.vimrc.local") | |
source ~/.vimrc.local | |
endif | |
augroup reload_vimrc " { | |
autocmd! | |
autocmd BufWritePost $MYVIMRC source $MYVIMRC | |
augroup END " } | |
"here is a more exotic version of my original Kwbd script | |
"delete the buffer; keep windows; create a scratch buffer if no buffers left | |
function s:Kwbd(kwbdStage) | |
if(a:kwbdStage == 1) | |
if(!buflisted(winbufnr(0))) | |
bd! | |
return | |
endif | |
let s:kwbdBufNum = bufnr("%") | |
let s:kwbdWinNum = winnr() | |
windo call s:Kwbd(2) | |
execute s:kwbdWinNum . 'wincmd w' | |
let s:buflistedLeft = 0 | |
let s:bufFinalJump = 0 | |
let l:nBufs = bufnr("$") | |
let l:i = 1 | |
while(l:i <= l:nBufs) | |
if(l:i != s:kwbdBufNum) | |
if(buflisted(l:i)) | |
let s:buflistedLeft = s:buflistedLeft + 1 | |
else | |
if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump) | |
let s:bufFinalJump = l:i | |
endif | |
endif | |
endif | |
let l:i = l:i + 1 | |
endwhile | |
if(!s:buflistedLeft) | |
if(s:bufFinalJump) | |
windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif | |
else | |
enew | |
let l:newBuf = bufnr("%") | |
windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif | |
endif | |
execute s:kwbdWinNum . 'wincmd w' | |
endif | |
if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%")) | |
execute "bd! " . s:kwbdBufNum | |
endif | |
if(!s:buflistedLeft) | |
set buflisted | |
set bufhidden=delete | |
set buftype= | |
setlocal noswapfile | |
endif | |
else | |
if(bufnr("%") == s:kwbdBufNum) | |
let prevbufvar = bufnr("#") | |
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum) | |
b # | |
else | |
bn | |
endif | |
endif | |
endif | |
endfunction | |
command! Kwbd call s:Kwbd(1) | |
nnoremap <silent> <Plug>Kwbd :<C-u>Kwbd<CR> | |
" Create a mapping (e.g. in your .vimrc) like this: | |
" nmap <Leader>bc : call s:Kwbd(1) <Plug>Kwbd | |
" Highlight all instances of word under cursor, when idle. | |
" Useful when studying strange source code. | |
" Type z/ to toggle highlighting on/off. | |
nnoremap z/ :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR> | |
function! AutoHighlightToggle() | |
let @/ = '' | |
if exists('#auto_highlight') | |
au! auto_highlight | |
augroup! auto_highlight | |
setl updatetime=4000 | |
echo 'Highlight current word: off' | |
return 0 | |
else | |
augroup auto_highlight | |
au! | |
au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>' | |
augroup end | |
setl updatetime=500 | |
echo 'Highlight current word: ON' | |
return 1 | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment