Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
209 lines (165 sloc) 6.55 KB
""
"" Thanks:
"" Gary Bernhardt <destroyallsoftware.com>
"" Drew Neil <vimcasts.org>
"" Tim Pope <tbaggery.com>
"" Janus <github.com/carlhuda/janus>
""
set nocompatible
set encoding=utf-8
call pathogen#infect()
filetype plugin indent on
runtime macros/matchit.vim " enables % to cycle through `if/else/endif`
let g:solarized_termcolors=256
syntax enable
if has('gui_running')
set background=light
colorscheme jellybeans
" colorscheme solarized
else
set background=dark
set t_Co=256
colorscheme solarized
endif
"set nonumber " line numbers aren't needed
set ruler " show the cursor position all the time
set cursorline " highlight the line of the cursor
set showcmd " show partial commands below the status line
"set shell=bash " avoids munging PATH under zsh
"let g:is_bash=1 " default shell syntax
set shell=zsh
set history=200 " remember more Ex commands
set scrolloff=3 " have some context around the current line always on screen
" Allow backgrounding buffers without writing them, and remember marks/undo
" for backgrounded buffers
set hidden
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set list " Show invisible characters
set backspace=indent,eol,start " backspace through everything in insert mode
" List chars
set listchars="" " Reset the listchars
set listchars=tab:\ \ " a tab should display as " ", trailing whitespace as "."
set listchars+=trail:. " show trailing spaces as dots
set listchars+=extends:> " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set listchars+=precedes:< " The character to show in the first column when wrap is
" off and the line continues beyond the left of the screen
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
function s:setupWrapping()
set wrap
set wrapmargin=2
set textwidth=80
endfunction
if has("autocmd")
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make set noexpandtab
" Make sure all markdown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown | call s:setupWrapping()
" Treat JSON files like JavaScript
au BufNewFile,BufRead *.json set ft=javascript
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
" mark Jekyll YAML frontmatter as comment
au BufNewFile,BufRead *.{md,markdown,html,xml} sy match Comment /\%^---\_.\{-}---$/
endif
" don't use Ex mode, use Q for formatting
"map Q gq
" clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
let mapleader=" "
" paste lines from unnamed register and fix indentation
nmap <leader>p pV`]=
nmap <leader>P PV`]=
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>gf :CommandTFlush<cr>\|:CommandT features<cr>
map <leader>gg :topleft 100 :split Gemfile<cr>
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr>
map <leader>m :ls<CR>:e #
let g:CommandTMaxHeight=10
let g:CommandTMinHeight=4
" ignore Rubinius, Sass cache files
set wildignore+=tmp/**,*.rbc,.rbx,*.scssc,*.sassc
nnoremap <leader><leader> <c-^>
" find merge conflict markers
nmap <silent> <leader>cf <ESC>/\v^[<=>]{7}( .*\|$)<CR>
command! KillWhitespace :normal :%s/ *$//g<cr><c-o><cr>
" easier navigation between split windows
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
set backupdir=~/.vim/_backup " where to put backup files.
set directory=~/.vim/_temp " where to put swap files.
if has("statusline") && !&cp
set laststatus=2 " always show the status bar
" Start the status line
set statusline=%f\ %m\ %r
" Add fugitive
set statusline+=%{fugitive#statusline()}
" Finish the statusline
set statusline+=Line:%l/%L[%p%%]
set statusline+=Col:%v
set statusline+=Buf:#%n
set statusline+=[%b][0x%B]
endif
"""""""""""""""MY STUFF"""""""""""""""""""""
set number "show line numbers
set nocursorline "for some reason was slowing down scrolling
nnoremap <leader>w <C-w>v<C-w>l
let g:netrw_preview = 1 "press p to preview file it netrw
cabbr <expr> %% expand('%:p:h') "makes %% the directory of current file when opening new files
nnoremap <silent> K :GitGrep <cword><CR> "K to grep for current word
nnoremap <silent> vv <C-w>v "vv vertical split
"""""Smart Window Close(from https://github.com/skwp/dotfiles/blob/master/vim/plugin/settings/yadr-window-killer.vim)"""""""
" Use Q to intelligently close a window
" (if there are multiple windows into the same buffer)
" or kill the buffer entirely if it's the last window looking into that
" buffer
function! CloseWindowOrKillBuffer()
let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')"))
" We should never bdelete a nerd tree
if matchstr(expand("%"), 'NERD') == 'NERD'
wincmd c
return
endif
if number_of_windows_to_this_buffer > 1
wincmd c
else
bdelete
endif
endfunction
nnoremap <silent> Q :call CloseWindowOrKillBuffer()<CR>
map <leader>t :NERDTreeToggle<CR>
if filereadable(".vim.custom")
so .vim.custom
endif
imap jj <Esc>
" cd to the directory containing the file in the buffer
nmap <silent> <leader>cd :lcd %:h<CR>
"
" " Create the directory containing the file in the buffer
nmap <silent> <leader>md :!mkdir -p %:p:h<CR>
" hybrid number mode (vim 7.4+ only)
" http://jeffkreeftmeijer.com/2013/vims-new-hybrid-line-number-mode/
set relativenumber
set number