Skip to content

Instantly share code, notes, and snippets.

@neagle
Created February 3, 2016 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neagle/d890b7ecc4247d82de22 to your computer and use it in GitHub Desktop.
Save neagle/d890b7ecc4247d82de22 to your computer and use it in GitHub Desktop.
" _
" ___ __ _ __ _| | ___
" / _ \/ _` |/ _` | |/ _ \
"| __/ (_| | (_| | | __/
" \___|\__,_|\__, |_|\___|
" |___/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype off " required!
" Use Vundle to manage bundles (plugins) and keep them up-to-date
" https://github.com/gmarik/vundle
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/syntastic'
"Plugin 'wookiehangover/jshint.vim'
Plugin 'edsono/vim-matchit'
Plugin 'scrooloose/nerdcommenter'
Plugin 'tpope/vim-surround'
Plugin 'digitaltoad/vim-jade'
Plugin 'evidens/vim-twig'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'godlygeek/tabular'
" Display symbols next to lines in git projects that show changes, additions, and deletions
Plugin 'airblade/vim-gitgutter'
" Intelligently close HTML tags
Plugin 'docunext/closetag.vim'
" Git integration
Plugin 'tpope/vim-fugitive'
" Better JavaScript
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
" Utils (required for SnipMate)
Plugin 'marcweber/vim-addon-mw-utils'
" tlib (required for SnipMate)
Plugin 'tomtom/tlib_vim'
" SnipMate
Plugin 'garbas/vim-snipmate'
" Snippets for SnipMate
Plugin 'honza/vim-snippets'
Plugin 'dhruvasagar/vim-table-mode'
" YouCompleteMe
" Plugin 'Valloric/YouCompleteMe'
" Plugin 'jelera/vim-javascript-syntax'
Plugin 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
" Plugin 'marijnh/tern_for_vim'
Plugin 'leafgarland/typescript-vim'
"Plugin 'Shougo/unite.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'posva/vim-vue'
Plugin 'cakebaker/scss-syntax.vim'
call vundle#end()
filetype plugin indent on " required!
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" syntax highlight
syntax on
filetype on
"filetype plugin on
" http://vim.wikia.com/wiki/Omni_completion
set ofu=syntaxcomplete#Complete
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/
" Prevent some security exploits having to do with modelines in files.
set modelines=0
" Store undo history in an external file - allows undoing even if the file
" has been closed and reopened
set undofile
set undodir=~/.vim/undo
set backupdir=~/.vim/backup
set noswapfile
" http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file
" set autochdir
nnoremap ,cd :cd %:p:h<CR>
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM User Interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap leader character to comma - easier to reach than \ (the default)
let mapleader = ","
set ruler " show the cursor position all the time
set number " show line numbers
" UTF-8 Encoding
set encoding=utf-8
" Keep 3 lines from previous page when scrolling
set scrolloff=3
" Displays the current mode (i.e. -- INSERT --, -- VISUAL --, etc.)
set showmode
" Show partial commands
set showcmd
" Always show the last status
set laststatus=2
" http://blog.interlinked.org/tutorials/vim_tutorial.html
" long lines
" set wrap
" Expand the command line using tab
" set wildchar=<Tab>
" show line numbers
set number
" Folding
" Save and reload fold state
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview
" Fold using markers {{{
" like this
" }}}
"set foldmethod=marker
" powerful backspaces
set backspace=indent,eol,start
" Search Configuration
set ignorecase " Ignore case while searching.
set smartcase " When uppercase is used, do case sensitive search.
set gdefault " Enable global search/replace (/g/) by default.
set hlsearch " highlight the searchterms
set incsearch " jump to the matches while typing
set showmatch " Show matching brackets when text indicator is over them
"
" Clear search results with leader + space
nnoremap <leader><space> :noh<cr>
" Easily edit the .vimrc file
nmap <leader>v :vsplit $MYVIMRC<CR>
au WinLeave * set nocursorline nocursorcolumn
au WinEnter * set cursorline cursorcolumn
set cursorline cursorcolumn
" Toggle the color column
nmap <leader>tc :call ToggleColorColumn()<CR>
function! ToggleColorColumn()
if &colorcolumn == 0
execute "set colorcolumn=80,120"
else
execute "set colorcolumn=0"
endif
endfunction
" Turn on the color column initially
"call ToggleColorColumn()
" Source the vimrc file after saving it
if has("autocmd")
autocmd! bufwritepost .vimrc nested source $MYVIMRC
endif
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
" Use tab - which is much easier to reach than % - to navigate bracket pairs
"nnoremap <tab> %
"vnoremap <tab> %
nmap <tab> %
vmap <tab> %
" Visual mode blockwise indent
" This keeps the current visual block selection active after changing indent
" with '<' or '>'. Usually the visual block selection is lost after you shift
" it, which is incredibly annoying.
vmap > >gv
vmap < <gv
" Select the text you just pasted with 'gp'
" http://vim.wikia.com/wiki/Selecting_your_pasted_text
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
" Autosave when focus is lost.
au FocusLost * :wa
" Use ctrl + c/x to copy/cut visual mode selection to OS X clipboard (pasteboard)
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
nmap <leader>gc :call CopyEntireFile()<CR>
function! CopyEntireFile()
let lline=line(".")
"execute 'echo lline'
execute 'normal! ggVG'
execute 'silent !pbcopy'
execute ':redraw!'
execute 'normal! V' . lline . 'G'
endfunction
" Set word wrap character limit.
" set textwidth=0
"set textwidth=79
" Not sure what this formatting does, but it is recommended.
"set formatoptions=qrn1
set list
set listchars=tab:▸\ ,eol
" http://stackoverflow.com/questions/4726882/how-do-you-change-the-background-color-of-the-empty-tab-space-in-vim
"hi TabLineFill term=bold cterm=bold ctermbg=0
" history
set history=50
" 1000 undo levels
set undolevels=1000
" write before hiding a buffer
set autowrite
" allows hidden buffers to stay unsaved
set hidden
" Enable the wild menu.
set wildmenu
set wildmode=list:longest
" Use visual bell instead of beeping when doing something wrong
set visualbell
" Highlight the current line.
" This setting is on probation - it looks great in MacVim and horrible in
" terminal
set cursorline
" Improves redrawing.
set ttyfast "set wmh=0
" we use a dark background, don't we?
set background=dark
" Always show the menu, insert longest match
set completeopt=menuone,longest
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Map visual editor to key directions.
map <C-J> <C-W>j
map <C-K> <C-W>k
map <c-h> <c-w>h
map <c-l> <c-w>l
" Turn off the arrow keys - learn to use hjkl
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" Open helpfiles in a vertical split
augroup helpfiles
au!
au BufRead,BufEnter */doc/* wincmd L
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Windows, Splits, and Tabs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Make sure new file explorer splits are equal width/height
"let g:netrw_winsize = 70
" Map new file explorer splits to <leader>s + <direction>
nnoremap <leader>sk :Hex!<cr>
nnoremap <leader>sl :Vex!<cr>
nnoremap <leader>sj :Hex<cr>
nnoremap <leader>sh :Vex<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 256 colors
set t_Co=256
syntax enable
colorscheme monokai-soda
" Set your color scheme in .vimrc.supplemental - this is one place it's
" okay to be different.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab, and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set shiftwidth=2
set tabstop=2
"set expandtab
"set shiftwidth=4
" Set shiftwidth to 2 for heavily nested filetypes
autocmd FileType javascript setlocal shiftwidth=2
autocmd FileType javascript setlocal tabstop=2
autocmd FileType javascript setlocal softtabstop=2
autocmd FileType html setlocal shiftwidth=2
autocmd FileType html setlocal tabstop=2
autocmd FileType html setlocal softtabstop=2
autocmd FileType scss setlocal shiftwidth=2
autocmd FileType scss setlocal tabstop=2
autocmd FileType scss setlocal softtabstop=2
"set softtabstop=4
"set tabstop=4
"set smarttab
"set autoindent
" Code completion.
" autocmd FileType python set omnifunc=pythoncomplete#Complete
" autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
" autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
" autocmd FileType css set omnifunc=csscomplete#CompleteCSS
" autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
" autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" autocmd FileType c set omnifunc=ccomplete#Complete
" http://vim.wikia.com/wiki/Example_vimrc
" Set the command window height to 2 lines, to avoid many cases of
" having to "press <Enter> to continue"
set cmdheight=2
" Automatically strip trailing whitespace on file save.
"autocmd BufWritePre * :%s/\s\+$//e
" Automatically toggle paste mode
:imap <D-V> ^O"+p
" Automatically label windows in Tmux
" https://vi.stackexchange.com/questions/3897/how-to-label-tmux-tabs-with-the-name-of-the-file-edited-in-vim?newreg=6c6f132c9f8b4be3ad71f6012943b969
"autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window 'vim | " . expand("%:t") . "'")
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Custom Filetypes
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.zsh setlocal filetype=zsh
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Awesome Sauce
" Crazy, useful stuff for doing particular, awesome things.
"
" By implication, other settings should be more general.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Create a new line below the current one of the same length with = chars
nnoremap <leader>1 yypVr=
nnoremap <leader>2 yypVr-
" Add a timestamp
nnoremap <leader>T "=strftime("%c")<cr>P
" Add real arrows
nnoremap <leader><right> a→<esc>
nnoremap <leader><left> a←<esc>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Textile Config
" Open :TextilePreview() in Chrome rather than Safari
let g:TextileBrowser="Google Chrome"
" Syntastic Mode
nnoremap <leader>e :Errors<cr>
" Syntastic Settings
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']
let g:syntastic_phpcs_conf='--standard=PSR2 --tab-width=4'
let g:syntastic_javascript_checkers=['jshint']
" let g:syntastic_javascript_checkers=['jshint']
" https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt#L238
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['scss'] }
nnoremap <leader>n :lnext<cr>
" Nerd Commenter Settings
let g:NERDSpaceDelims='1'
let g:Powerline_symbols = 'fancy'
"nnoremap <c-\> :CtrlP<CR>
"nnoremap <c-s-\> :CtrlPBuffer<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Supplemental
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maybe there are some things you want in your .vimrc that you REALLY
" can't get everyone else to agree to. Put them in .vimrc.supplemental
runtime .vimrc.supplemental
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment