Skip to content

Instantly share code, notes, and snippets.

@emmajane
Created May 19, 2015 22:51
Show Gist options
  • Save emmajane/9255e049173b8a0b7ec8 to your computer and use it in GitHub Desktop.
Save emmajane/9255e049173b8a0b7ec8 to your computer and use it in GitHub Desktop.
set nocompatible " Be Vimproved.
filetype off " Enable after Vundle
" Vundle Bundle is Wundleful
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" GitHub bundles:
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-haml'
Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-rake'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-git'
Bundle 'pangloss/vim-javascript'
Bundle 'kchmck/vim-coffee-script'
Bundle 'othree/html5.vim'
Bundle 'mutewinter/nginx.vim'
Bundle 'Lokaltog/vim-powerline'
Bundle 'digitaltoad/vim-jade'
Bundle 'scrooloose/syntastic'
Bundle 'scrooloose/nerdtree'
filetype plugin indent on
" UltiSnip
set runtimepath+=~/.vim/bundle/ultisnips
let g:UltiSnipsSnippetDirectories=['UltiSnips','snippets']
let g:UltiSnipsUsePythonVersion = 2
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let did_UltiSnips_snipmate_compatibility = 1
" omnicomplete navigation with arrows? NEVAR!!1!
inoremap <expr> j pumvisible() ? "\<down>" : "j"
inoremap <expr> k pumvisible() ? "\<up>" : "k"
" Syntax highlighting options
set t_Co=256
syntax on
" Colors
set background=dark
" Change mapleader. Really nice for Dvorak.
let mapleader=","
" Local directories
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
set undodir=~/.vim/undo
" Global UI Settings
set autoindent
set backspace=indent,eol,start
set cursorline " Highlight current line
set encoding=utf-8 nobomb " Set encoding without BOM
set expandtab " Expand tabs to spaces
set foldcolumn=4 " Column to show folds
set foldenable
set foldlevel=2
set foldmethod=syntax
set foldminlines=0
set foldnestmax=3
set hidden " When a buffer is brought to foreground, remember undo history and marks.
set history=1000
set hlsearch " Highlight searches
set ignorecase
set incsearch " Highlight incrementally as search is typed
set laststatus=2 " Always show status line
set magic " Enable extended regexes.
set noerrorbells
set nojoinspaces " Only insert single space after a '.', '?' and '!' with a join command
set nostartofline " Don't reset cursor when moving around
set nowrap
set number
set scrolloff=3
set shiftwidth=2
set shortmess=atI " Don't show the intro message when starting up
set showmode
set showtabline=2
set smartcase
set smarttab
set softtabstop=2
set suffixes=.bak,~,.swp,.swo,.info,.aux,.log,.pdf,.bin,.dmg,.exe,.out,.module,.inc,.pyd,.pyc,.dll
set title " Show filename in titlebar
set ttyfast
set undofile " Persistent undo
set wrapscan " Searches wrap around end of file
" Powerline
let g:Powerline_symbols = 'fancy'
set guifont=Inconsolata-dz-Powerline.otf
" Speed up viewport scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Sudo write (,W)
noremap <leader>W :w !sudo tee %<CR>
" Remap :W to :w because clumsy
command W w
" Disable arrow keys
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Disable HJKL
" map h <nop>
" map j <nop>
" map k <nop>
" map l <nop>
" Use arrows for arrows in insert mode
imap <up> ↑
imap <down> →
imap <left> ←
imap <right> →
" Highlight redundant whitespace
highlight RedundantSpaces ctermbg=cyan guibg=black
match RedundantSpaces /\s\+$\| \+\ze\t\|\t/
" Strip trailing whitespace (,ss)
function! StripWhitespace ()
let save_cursor = getpos('.')
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
noremap <leader>ss :call StripWhitespace ()<CR>
" Toggle paste mode (,p)
set pastetoggle=<leader>p
map <leader>p :set invpaste paste?<CR>
" Yank from cursor to end of line
nnoremap Y y$
" Toggle folds
nnoremap <silent> <space> :exe 'silent! normal! '.((foldclosed('.')>0)? 'zMzx' : 'zc')<CR>
" JSON
au BufRead,BufNewFile *.json set ft=json syntax=javascript
" Jade
au BufRead,BufNewFile *.jade set ft=jade syntax=jade
" Ruby
au BufRead,BufNewFile Rakefile,Capfile,Gemfile,.autotest,.irbrc,*.treetop,*.tt set ft=ruby syntax=ruby
" Coffeescript
au BufRead,BufNewFile *.coffee setl foldmethod=indent nofoldenable
" ZSH
au BufRead,BufNewFile .zsh_rc,.functions,.commonrc set ft=zsh
" Drupal
au BufRead,BufNewFile *.module set filetype=php
au BufRead,BufNewFile *.install set filetype=php
au BufRead,BufNewFile *.view set filetype=php
au BufRead,BufNewFile *.inc set filetype=php
au BufRead,BufNewFile *.profile set filetype=php
" SASS
au BufNewFile,BufRead *.scss setlocal filetype=sass
" LESS
au BufNewFile,BufRead *.less setlocal filetype=less
" Markdown
au BufNewFile,BufRead *.m*down setlocal filetype=markdown
au BufRead,BufNewFile *.md setlocal textwidth=80
au BufRead,BufNewFile *.md setlocal spell
" HTML
let g:html_indent_tags = 'li\|p' " <li> & <p> are block tags
" Alt navigation for vertical splits
:nmap <silent> <C-h> :wincmd h<CR>
:nmap <silent> <C-s> :wincmd l<CR>
" Toggle NerdTree
map <leader>nt :NERDTreeToggle<CR>
" Remap native omnicompletion: ,,
imap <leader>, <C-x><C-o>
" Switch tabs with ,. and ,'
nnoremap <leader>. :tabn<CR>
nnoremap <leader>' :tabp<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment