Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 227 additions and 191 deletions.
  1. +50 −76 .vim/key_mappings.vim
  2. +172 −113 .vimrc
  3. +5 −2 .zsh/aliases.zsh
View
126 .vim/key_mappings.vim
@@ -1,125 +1,99 @@
" get out of insert mode with cmd-i
- imap <D-i> <Esc>
+imap <D-i> <Esc>
" Seriously, it's not like :W is bound to anything anyway.
- command! W :w
+command! W :w
" redo with U
- nmap U :redo<cr>
+nmap U :redo<cr>
" easy wrap toggling
- nmap <Leader>w :set wrap<cr>
- nmap <Leader>W :set nowrap<cr>
+nmap <Leader>w :set wrap<cr>
+nmap <Leader>W :set nowrap<cr>
" switch windows with g+movement
- nmap gj <C-W>j
- nmap gk <C-W>k
- nmap gh <C-W>h
- nmap gl <C-W>l
+nmap gj <C-W>j
+nmap gk <C-W>k
+nmap gh <C-W>h
+nmap gl <C-W>l
" swap windows
- nmap gS <C-W><C-R>
+nmap gS <C-W><C-R>
" close all other windows (in the current tab)
- nmap gW :only<cr>
-
-" Opens an edit command with the path of the currently edited file filled in
- cnoremap %% <C-R>=expand("%:h").'/'<cr>
- map <Leader>e :edit %%
- map <Leader>v :view %%
- map <leader>mv :call RenameFile()<cr>
-
-" map keys to go to specific files
- map <leader>gr :topleft :split config/routes.rb<cr>
- map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>
- map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr>
- map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr>
- map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr>
- map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
- map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr>
- map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets<cr>
- map <leader>gg :topleft 100 :split Gemfile<cr>
- map <leader>gi :CommandTFlush<cr>\|:CommandT integration_spec<cr>
-
- let g:CommandTCursorStartMap='<leader>f'
- map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
- map <leader>gf :CommandTFlush<cr>\|:CommandT %%<cr>
+nmap gW :only<cr>
" Reopen the last buffer in the current window
- nnoremap <leader><leader> <c-^>
-
-" Remap tab key to do autocomletion or indentation depending on the context
- inoremap <tab> <c-r>=InsertTabWrapper()<cr>
- inoremap <s-tab> <c-n>
+nnoremap <leader><leader> <c-^>
" Tab mappings.
- map <Leader>tt :tabnew<cr>
- map <Leader>te :tabe %%
- map <Leader>tc :tabclose<cr>
- map <Leader>to :tabonly<cr>
- map <Leader>tn :tabnext<cr>
- map <Leader>tp :tabprevious<cr>
- map <Leader>tf :tabfirst<cr>
- map <Leader>tl :tablast<cr>
- map <Leader>tm :tabmove
+map <Leader>tt :tabnew<cr>
+map <Leader>te :tabe %%
+map <Leader>tc :tabclose<cr>
+map <Leader>to :tabonly<cr>
+map <Leader>tn :tabnext<cr>
+map <Leader>tp :tabprevious<cr>
+map <Leader>tf :tabfirst<cr>
+map <Leader>tl :tablast<cr>
+map <Leader>tm :tabmove
" NERDTree
- map <Leader>n :NERDTreeToggle<cr>
+map <Leader>n :NERDTreeToggle<cr>
" previous/next buffer (for going without tabs)
- nmap g[ :bp<cr>
- nmap g] :bn<cr>
+nmap g[ :bp<cr>
+nmap g] :bn<cr>
" ack for project-wide searching (TRAILING WHITESPACE IS INTENTIONAL)
- nmap g/ :Ack!
- nmap g* :Ack! -w <C-R><C-W>
- nmap gA :AckAdd!
- nmap gn :cnext<cr>
- nmap gp :cprev<cr>
- nmap gq :ccl<cr>
+nmap g/ :Ack!
+nmap g* :Ack! -w <C-R><C-W>
+nmap gA :AckAdd!
+nmap gn :cnext<cr>
+nmap gp :cprev<cr>
+nmap gq :ccl<cr>
" search and replace the word under the cursor
- nnoremap <Leader>r :%s/\<<C-r><C-w>\>/
+nnoremap <Leader>r :%s/\<<C-r><C-w>\>/
" remove search hilighting
- nmap <silent> <Leader>h :silent :nohlsearch<CR>
+nmap <silent> <Leader>h :silent :nohlsearch<CR>
" rapidly toggle `set list`
- nmap <leader>l :set list!<CR>
+nmap <leader>l :set list!<CR>
" clear up trailing white space
- nmap <leader>s :%s/\s\+$//<CR>
+nmap <leader>s :%s/\s\+$//<CR>
" full blame for Git and Mercurial
- vmap <Leader>g :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
- vmap <Leader>h :<C-U>!hg blame -fu <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
+vmap <Leader>g :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
+vmap <Leader>h :<C-U>!hg blame -fu <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
" shortcuts for frequenly used files
" nmap gs :e db/schema.rb<cr>
" nmap gr :e config/routes.rb<cr>
" align pipe-separated tables for cucumber or textile with g| in visual mode
- vmap g\| :Align \|<cr>
+vmap g\| :Align \|<cr>
" insert blank lines without going into insert mode
- nmap go o<esc>
- nmap gO O<esc>
+nmap go o<esc>
+nmap gO O<esc>
" open the source in a browser for distribution or copying as RTF
- nmap gH :OpenHtml<CR>
+nmap gH :OpenHtml<CR>
" Bubble single lines (uses unimpaired.vim)
- nmap <C-Up> [e
- nmap <C-Down> ]e
+nmap <C-Up> [e
+nmap <C-Down> ]e
" Bubble multiple lines
- vmap <C-Up> [egv
- vmap <C-Down> ]egv
+vmap <C-Up> [egv
+vmap <C-Down> ]egv
" scroll up/down one line at a time
- nmap <Up> <C-Y>
- nmap <Down> <C-E>
+nmap <Up> <C-Y>
+nmap <Down> <C-E>
" scroll up/down 3 lines at a time
- nnoremap <C-Y> 3<C-Y>
- nnoremap <C-E> 3<C-E>
+nnoremap <C-Y> 3<C-Y>
+nnoremap <C-E> 3<C-E>
" scroll left/right
- nmap <Left> zh
- nmap <Right> zl
+nmap <Left> zh
+nmap <Right> zl
View
285 .vimrc
@@ -1,13 +1,21 @@
-" Basic Vim Config
+" This is Steven Harman's .vimrc file.
+" What you'll find here is a mix of ideas I've stolen from others and my own
+" preference for how it should be done. Good luck!
+" vim:set ts=2 sts=2 sw=2 expandtab:
-set nocompatible " Must come first because it changes other options.
+" Must come first because it changes other options.
+set nocompatible
-filetype plugin off " Trun off for Vundler. Turn it back on below.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" VUNDLE FOR MANAGING PLUGINS
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Turn off for Vundle. Turn it back on below.
+filetype plugin off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
-" let Vundle manage Vundle. Required!
+" manage Vundle with Vundle. BOOM!
Bundle 'gmarik/vundle'
" original repos on github
@@ -35,69 +43,108 @@ Bundle 'taglist.vim'
" vim-less - for LESS.js/dotLESS
Bundle 'git://gist.github.com/369178.git'
-syntax enable " Turn on syntax highlighting.
-filetype plugin indent on " Turn on file type detection.
-
-runtime macros/matchit.vim " Load the matchit plugin.
-
-set showcmd " Display incomplete commands.
-set showmode " Display the mode you're in.
-set showmatch " Show matching parens
-"set complete=.,t " Only use current file and ctags for complete
-set completeopt=longest,menuone " Use longest text of all matches, even if only one match
-
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" BASIC EDITING CONFIGURATION
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" allow unsaved background buffers and remember marks/undo for them
+set hidden
+" remember more commands and search history
+set history=10000
+set expandtab
+" Tabs or spaces? Spaces!
+set tabstop=2
+set shiftwidth=2
+set softtabstop=2
+set autoindent
+set showmatch
+set incsearch
+set hlsearch
+" Case-insensitive searching
+set ignorecase
+" Unless expression contains a capital letter.
+set smartcase
+set mouse=a
+set ruler
+set number
+" highlight current line
+set cursorline
+set title
+set switchbuf=useopen
+set winwidth=79
+" We have to have a winheight bigger than we want to set winminheight. But if
+" we set winheight to be huge before winminheight, the winminheight set will
+" fail.
+set winheight=5
+set winminheight=5
+set winheight=999
+set shell=bash
+" Prevent Vim from clobbering the scrollback buffer. See
+" http://www.shallowsky.com/linux/noaltscreen.html
+set t_ti= t_te=
+set scrolloff=3 " Show 3 lines of context around the cursor.
+set nobackup " Don't make a backup before overwriting a file.
+set nowritebackup " And again.
+set backupdir=./tmp,$HOME/.vim/tmp/,$TEMP/,.
+set directory=./tmp,$HOME/.vim/tmp/,$TEMP/,.
+set tags=./tmp/tags,./tags,./.tags,tags,TAGS
set backspace=indent,eol,start " Intuitive backspacing in insert mode.
-
-set hidden " Handle multiple buffers better.
-
-set wildmenu " Enhanced command line completion.
-set wildmode=list:longest " Complete files like a shell.
-set mouse=a " Have the mouse enabled all the time.
-
-set ignorecase " Case-insensitive searching.
-set smartcase " But case-sensitive if expression contains a capital letter.
-
-set cursorline " highlight current line
-"hi CursorLine cterm=none ctermbg=black
-
-set number " Show line numbers.
-set ruler " Show cursor position.
" custom whitespace characters
set listchars=tab:\ ,eol:¬,trail:~,extends:>,precedes:<
-
+set showcmd " Display incomplete commands.
+" sane split directions
+set splitright
+set splitbelow
set autoread " Set to auto read when a file is changed from the outside
+set visualbell " No beeping.
-set incsearch " Highlight matches as you type.
-set hlsearch " Highlight matches.
+syntax enable " Turn on syntax highlighting.
-set gdefault " assume the /g flag on :s substitutions to replace all matches in a line:
+filetype plugin indent on " Turn on file type detection.
+set wildmode=list:longest
+" make tab completion for files/buffers act like bash
+set wildmenu
-set wrap " Turn on line wrapping.
-set scrolloff=3 " Show 3 lines of context around the cursor.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" CUSTOM AUTOCMDS
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+augroup vimrcEx
+ " Clear all autocmds in the group
+ autocmd!
+ autocmd FileType text setlocal textwidth=78
+ " Jump to last cursor position unless it's invalid or in an event handler
+ autocmd BufReadPost *
+ \ if line("'\"") > 0 && line("'\"") <= line("$") |
+ \ exe "normal g`\"" |
+ \ endif
-set title " Set the terminal's title
+ "for ruby, autoindent with two spaces, always expand tabs
+ autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
+ autocmd FileType python set sw=4 sts=4 et
-"let g:syntastic_enable_signs=1 "mark syntax errors with :signs
+ "autocmd! BufRead,BufNewFile *.sass setfiletype sass
-set visualbell " No beeping.
+ autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:&gt;
+ autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:&gt;
-set nobackup " Don't make a backup before overwriting a file.
-set nowritebackup " And again.
-set directory=./tmp,$HOME/.vim/tmp/,$TEMP/,. " Keep swap files in one location
-set tags=./tmp/tags,./tags,tags
+ " Indent p tags
+ autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
+augroup END
-" Tabs or spaces? Spaces!
-set tabstop=2 " Global tab width.
-set shiftwidth=2 " how many columns are indented with reindent operations
-set softtabstop=2 " how many columns to use when you hit 'tab' (generally keep equal to shiftwidth)
-set expandtab " Use spaces instead of tabs
-set autoindent
-
-" sane split directions
-set splitright
-set splitbelow
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" COLORS
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" let the terminal determine the colors to use
+set background=dark
+if has("gui_running") || &t_Co >= 256
+ :color molokai
+else
+ set t_Co=16 " every terminal I use supports at least 16, right?
+ :color solarized " a 16-color safe theme
+endif
-" a more useful statusline
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" STATUS LINE
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set statusline=[%n] "current buffer number
set statusline+=\ %f "tail of the filename
@@ -142,10 +189,12 @@ set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
-set laststatus=2 " Show the status line all the time
+set laststatus=2 " Show the status line all the time
+"hi CursorLine cterm=none ctermbg=black
"recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
+
"return '[\s]' if trailing white space is detected
"return '' otherwise
function! StatuslineTrailingSpaceWarning()
@@ -198,27 +247,31 @@ function! FileEncodingAndBomb()
endfunction
-" let the terminal determine the colors to use
-if has("gui_running") || &t_Co >= 256
- :color molokai
-else
- set t_Co=16 " every terminal I use supports at least 16, right?
- :color solarized " a 16-color safe theme
-endif
-
-set foldmethod=indent
-set foldnestmax=10 "deepest fold is 10 levels
-set foldlevel=1
-set nofoldenable "dont fold by default
-
-" Automatic fold settings for specific files.
-let ruby_fold=1
-" autocmd FileType ruby setlocal foldmethod=syntax
-" autocmd FileType css setlocal foldmethod=indent shiftwidth=2 tabstop=2
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" MULTIPURPOSE TAB KEY
+" Indent if we're at the beginning of a line. Else, do completion.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+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>
+inoremap <s-tab> <c-n>
-" For the MakeGreen plugin and Ruby RSpec. Uncomment to use.
-autocmd BufNewFile,BufRead *_spec.rb compiler rspec
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" OPEN FILES IN DIRECTORY OF CURRENT FILE
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+cnoremap %% <C-R>=expand('%:h').'/'<cr>
+map <leader>e :edit %%
+map <leader>v :view %%
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" RENAME CURRENT FILE
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
@@ -228,43 +281,55 @@ function! RenameFile()
redraw!
endif
endfunction
+map <leader>n :call RenameFile()<cr>
-function! ShowColors()
- let num = 255
- while num >= 0
- exec 'hi col_'.num.' ctermbg='.num.' ctermfg=white'
- exec 'syn match col_'.num.' "ctermbg='.num.':...." containedIn=ALL'
- call append(0, 'ctermbg='.num.':....')
- let num = num - 1
- endwhile
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" PROMOTE VARIABLE TO RSPEC LET
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+function! PromoteToLet()
+ :normal! dd
+ :normal! P
+ :.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
+ :normal ==
endfunction
+:command! PromoteToLet :call PromoteToLet()
+:map <leader>p :PromoteToLet<cr>
-" do autocompletion or indentation depending on the context
-function! InsertTabWrapper()
- let col = col('.') - 1
- if !col || getline('.')[col - 1] !~ '\k'
- return "\<tab>"
- else
- return "\<c-p>"
- endif
-endfunction
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" MAPS TO JUMP TO SPECIFIC COMMAND-T TARGETS AND FILES
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+map <leader>gr :topleft :split config/routes.rb<cr>
+map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>
+map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr>
+map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr>
+map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr>
+map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
+map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr>
+map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets<cr>
+map <leader>gg :topleft 100 :split Gemfile<cr>
+map <leader>gt :CommandTFlush<cr>\|:CommandTTag<cr>
+map <leader>gi :CommandTFlush<cr>\|:CommandT integration_spec<cr>
+let g:CommandTCursorStartMap='<leader>f'
+map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
+map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Running tests
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
-" vim-makegreen binds itself to ,t unless something else is bound to its
-" function.
-map <leader>\dontstealmymapsmakegreen :w\|:call MakeGreen('spec')<cr>
-
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
- :silent !echo;echo;echo;echo;echo
- if filereadable("script/test")
- exec ":!script/test " . a:filename
+ :silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
+ if match(a:filename, '\.feature$') != -1
+ exec ":!script/features " . a:filename
else
- exec ":!bundle exec rspec " . a:filename
+ if filereadable("script/test")
+ exec ":!script/test " . a:filename
+ elseif filereadable("Gemfile")
+ exec ":!bundle exec rspec --color " . a:filename
+ else
+ exec ":!rspec --color " . a:filename
+ end
end
endfunction
@@ -281,8 +346,8 @@ function! RunTestFile(...)
endif
" Run the tests for the previously-marked file.
- let in_spec_file = match(expand("%"), '_spec.rb$') != -1
- if in_spec_file
+ let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
+ if in_test_file
call SetTestFile()
elseif !exists("t:smh_test_file")
return
@@ -292,25 +357,19 @@ endfunction
function! RunNearestTest()
let spec_line_number = line('.')
- call RunTestFile(":" . spec_line_number)
+ call RunTestFile(":" . spec_line_number . " -b")
endfunction
map <leader>t :call RunTestFile()<cr>
map <leader>T :call RunNearestTest()<cr>
map <leader>a :call RunTests('spec')<cr>
map <leader>A :call RunTests('')<cr>
-set winwidth=84
-" We have to have a winheight bigger than we want to set winminheight. But if
-" we set winheight to be huge before winminheight, the winminheight set will
-" fail.
-set winheight=5
-set winminheight=5
-set winheight=999
-
-set shell=bash
-
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" localvimrc plugin
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:localvimrc_ask = 0 " Don't ask before sourcing local vimrc files
let g:localvimrc_sandbox = 0 " Don't source the found local vimrc files in a sandbox
+runtime macros/matchit.vim
runtime key_mappings.vim
View
7 .zsh/aliases.zsh
@@ -2,14 +2,17 @@
alias b='cd -'
alias cls='clear'
alias sr='screen -r'
-alias pg_start='pg_ctl -D ~/.pgdata -l ~/.pgdata/psql.log start'
-alias pg_stop='pg_ctl -D ~/.pgdata stop -s -m fast'
alias restart='touch tmp/restart.txt'
alias ajaxrdoc="rdoc --fmt ajax --exclude '.*generator.*' --exclude '.*test.*' --exclude '.*spec.*'"
+alias be='bundle exec'
alias spnr='rspec spec_no_rails'
alias devlog='tail -200 -f log/development.log'
alias testlog='tail -200 -f log/test.log'
alias gvim='mvim -p'
+alias mysql_start='mysql.server start'
+alias mysql_stop='mysql.server stop'
+alias pg_start='pg_ctl -D ~/.pgdata -l ~/.pgdata/psql.log start'
+alias pg_stop='pg_ctl -D ~/.pgdata stop -s -m fast'
alias redis_start='redis-server /usr/local/etc/redis.conf'
function gitdays {

No commit comments for this range

Something went wrong with that request. Please try again.