Skip to content

Instantly share code, notes, and snippets.

@shreve
Created December 25, 2016 03:22
Show Gist options
  • Save shreve/39fbf533fa8d14b86cb7a93940e03d21 to your computer and use it in GitHub Desktop.
Save shreve/39fbf533fa8d14b86cb7a93940e03d21 to your computer and use it in GitHub Desktop.
runtime macros/matchit.vim
execute pathogen#infect()
let mapleader="," " <Leader> = ,
filetype plugin indent on
" Theming and shit like that
syntax on
colorscheme smyck-modified
" hide dumb files in netrw
let g:netrw_list_hide= '\.DS_Store$,.*\.swp$,^\./$'
set nocompatible " stop behaving in a Vi-compatible way
set autoindent " keep indentation on a new line
set autoread " if a file updates, read it
set backspace=indent,eol,start " allow backspacing over everything in insert mode (:h fixdel if issues)
set backupdir=/tmp
set clipboard=unnamed
set cryptmethod=blowfish " use blowfish to encrypt a file
set cursorline cursorcolumn " crosshair
set directory=/tmp " keep temporary and backup files in ~/.vim
set expandtab " explicitly enable tab->space conversion
set exrc " allow execution of .vimrc files from `pwd`
set gdefault " use the /g flag by default for :s
set history=1000 " remember 1000 lines of history
set ignorecase " by default ignore case in search
set laststatus=2 " always display status line
set list listchars=tab:»·,trail:· " display extra whitespace
set nowrap " don't linewrap, just continue past window
set noswapfile " don't make swap files
set number " precede each line with file line number (only current line with relativenumber)
set relativenumber " display line numbers in relation to current line
set ruler " show line and column number of cursor
set scrolloff=2 " 2 lines of padding when scrolling buffer
set secure " disable autocmd from `pwd`/.vimrc
"set shellcmdflag=-ic " run interactive shell
set showcmd " show command as it's being typed
set showmatch " breifly jump to matching bracket
set shiftround " >> << round to multiple of shiftwidth
set shiftwidth=2 " number of spaces to use for each indention step
set smartcase " when a capital letter is used, turn off ignorecase
set smartindent " indent properly in c-like languages
set softtabstop=2 " number of spaces Tab 'feels like'
set tabstop=2 " number of spaces Tab takes up
set tags=.hg/tags,.git/tags " common ctags locations
set timeoutlen=750 " change timeout
set wildmenu " turns on menu used for tab-completion
set wildmode=longest:full,full " complete longest common string, and activate wildmenu
" syntax highlighting for .html.erb
au BufNewFile,BufRead *.html.erb set filetype=eruby
au BufNewFile,BufRead *.rake set filetype=ruby
" au BufNewFile,BufRead *.coffee set filetype=javascript
au BufNewFile,BufRead *.md set filetype=markdown
au BufNewFile,BufRead *.{js.liquid} set filetype=javascript
" When loading text files, wrap them and don't split up words.
au BufNewFile,BufRead *.{md,txt} setlocal wrap
au BufNewFile,BufRead *.{md,txt} setlocal lbr
au BufNewFile,BufRead *.{md,txt} setlocal nolist " Don't display whitespace
" Remove trailing whitespace on save for certain file types.
" Also, try to prevent the cursor from jumping
au BufWritePre *.{erb,slim,rb,rs,sass,html,js,haml,coffee,cpp} :call TrimWhiteSpace()
au BufWritePre * :call Unixify()
au BufWritePre *.sass :call TrimCSSPunc()
" Try to restore position
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" let netrwhistpath="/Users/shreve/dotfiles/vim/.netrwhist"
" au VimLeave * if filereadable(netrwhistpath) | call delete(netrwhistpath) | endif
" security measures when opening a file that has been VimCrypt'd
au BufReadPost * if &key != "" | set noswapfile nowritebackup viminfo= nobackup noshelltemp history=0 secure | endif
map <Leader>ac :Rcontroller application<cr>
map <Leader>al :Rlayout application<cr>
map <Leader>bc :silent ! open "http://basecamp.com/2257044/"<cr>:redraw!<cr>
map <Leader>c :Rcontroller
map <Leader>ca :e config/application.rb<cr>
map <Leader>cr :e config/routes.rb<cr>
map <Leader>css :Rstylesheet
map <Leader>ee :Explore<cr>
map <Leader>er :e.<cr>
map <Leader>el :e config/locales/en.yml<cr>
map <Leader>f :e test/factories/
map <Leader>h :Rhelper
map <Leader>ios :! open -a /Applications/Xcode.app/Contents/Applications/iPhone\ Simulator.app<cr>
map <Leader>js :Rjavascript
map <Leader>jv :call RunThisJavaClass()<cr>
map <Leader>l :e app/views/layouts/
map <Leader>m :Rmodel
map <Leader>pg :silent ! open /Applications/PG\ Commander.app<cr>
map <Leader>pr :silent ! touch tmp/restart.txt<cr>:redraw!<cr>
map <Leader>rc :silent ! rails c<cr><esc>:redraw!<cr>
map <Leader>rs :source ~/.vimrc<cr>
map <Leader>s :w!<cr>
map <Leader>te :! time rake -rminitest/pride test<cr>
map <Leader>ut :Runittest
map <Leader>v :Rview
" toggle paste mode
nnoremap <Leader>p :set paste! list! number! relativenumber!<cr>
" don't run autocommands on searches
nnoremap <leader>/ :noautocmd vimgrep /
" jump to the first line character on 0
nnoremap 0 ^
" Get off my lawn
noremap <Left> :echoe "Use h"<CR>
noremap <Right> :echoe "Use l"<CR>
noremap <Up> <C-e>
noremap <Down> <C-y>
" noremap <Up> :echoe "Use k"<CR>
" noremap <Down> :echoe "Use j"<CR>
" jump between tags more easily
" map <C-[> <C-t>
" allow saving as sudo
" http://stackoverflow.com/a/7078429/1893290
cmap w!! w !sudo tee > /dev/null %
" Prevent 'no command' error with incorrect capitalization
command! Q q
command! W w
" edit ~/.vimrc files
command! Vimrc :e ~/.vimrc
" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
command! -nargs=0 -bar Update if &modified
\| if empty(bufname('%'))
\| browse confirm write
\| else
\| confirm write
\| endif
\|endif
nnoremap <silent> <C-S> :<C-u>Update<CR>
inoremap <silent> <C-S> :<esc>Update<CR>
" Set tabstop, softtabstop and shiftwidth to the same value
command! -nargs=* Stab call Stab()
function! Stab()
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
if l:tabstop > 0
let &l:sts = l:tabstop
let &l:ts = l:tabstop
let &l:sw = l:tabstop
endif
call SummarizeTabs()
endfunction
function! SummarizeTabs()
try
echohl ModeMsg
echon 'tabstop='.&l:ts
echon ' shiftwidth='.&l:sw
echon ' softtabstop='.&l:sts
if &l:et
echon ' expandtab'
else
echon ' noexpandtab'
endif
finally
echohl None
endtry
endfunction
function! TrimWhiteSpace()
normal ms
%s/\s\+$//e
normal `s
endfunction
function! Unixify()
if (&ff ==? "dos")
normal ms
%s/
$//e
set ff=unix
normal `s
endif
endfunction
function! TrimCSSPunc()
normal ms
%s/;//e
%s/\s+{\s+//e
%s/\s?}\n//e
normal `s
endfunction
function! Copy()
normal '<,'>w ! pbcopy
endfunction
function! RunThisJavaClass()
silent !javac %
!java %:t:r
endfunction
function! Softwrap()
set formatoptions=1
set linebreak
set wrap
set nolist
set breakat=\ |@-+;:,./?^I
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
set foldcolumn=7
endfunction
function! BigFile()
syntax off
setlocal noswapfile bufhidden=unload undolevels=-1
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment