Created
July 17, 2012 14:12
-
-
Save j-manu/3129615 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" | |
"" Thanks: | |
"" Gary Bernhardt <destroyallsoftware.com> | |
"" Drew Neil <vimcasts.org> | |
"" Tim Pope <tbaggery.com> | |
"" Janus <github.com/carlhuda/janus> | |
"" | |
set nocompatible | |
" required by vundle | |
filetype off | |
"" Vundle | |
"" See :help vundle for more details | |
set runtimepath+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
" let Vundle manage Vundle | |
" required! by vundle | |
Bundle 'gmarik/vundle' | |
Bundle 'kchmck/vim-coffee-script' | |
Bundle 'mileszs/ack.vim' | |
Bundle 'pangloss/vim-javascript' | |
Bundle 'tpope/vim-markdown' | |
Bundle 'cakebaker/scss-syntax.vim' | |
Bundle 'vim-ruby/vim-ruby' | |
Bundle 'tpope/vim-rails' | |
Bundle 'bbommarito/vim-slim' | |
Bundle 'ervandew/supertab' | |
Bundle 'tpope/vim-surround' | |
Bundle 'fholgado/minibufexpl.vim' | |
Bundle 'puppetlabs/puppet-syntax-vim' | |
Bundle 'Gist.vim' | |
" Bundle 'jQuery' | |
" Themes | |
Bundle 'altercation/vim-colors-solarized' | |
syntax on | |
filetype plugin indent on " required by vundle | |
set encoding=utf-8 | |
set background=dark | |
set nonumber | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
" Allow backgrounding buffers without writing them, and remember marks/undo | |
" for backgrounded buffers | |
set hidden | |
"" Whitespace | |
set nowrap " don't wrap lines | |
set softtabstop=2 " a tab is two spaces | |
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 last column when wrap is | |
" off and the line continues beyond the right 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 | |
set ttyfast " smoother output, we're not on a 1200 dialup :) | |
set nostartofline " keep the horizontal cursor position when moving vertically | |
set wildmenu " Show autocomplete menus | |
set showmode " Show editing mode | |
set nospell " disable spellcheck | |
" Line endings should be Unix-style unless the file is from someone else. | |
set fileformat=unix | |
au BufNewFile * set fileformat=unix | |
function s:setupWrapping() | |
set wrap | |
set wrapmargin=2 | |
set textwidth=72 | |
endfunction | |
" In Makefiles, use real tabs, not tabs expanded to spaces | |
au FileType make set noexpandtab | |
" Make sure all mardown 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 | |
" provide some context when editing | |
set scrolloff=5 | |
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 | |
" Finish the statusline | |
set statusline+=Line:%l/%L[%p%%] | |
set statusline+=Col:%v | |
set statusline+=Buf:#%n | |
set statusline+=[%b][0x%B] | |
endif | |
set completeopt=longest " Only insert the longest common text of the matches | |
set completeopt+=menuone " Use the popup menu also when there is only one match. | |
" don't use Ex mode, use Q for formatting | |
map Q gq | |
" clear the search buffer when hitting return | |
nnoremap <CR> :nohlsearch<cr> | |
" http://stackoverflow.com/a/2555659 | |
"imap <D-V> "+p | |
" imap <D-v> ^O:set paste<Enter>^R+^O:set nopaste<Enter> | |
let mapleader="," | |
" toggle paste | |
nnoremap <leader>p :set paste!<cr>i*p<esc> | |
" find merge conflict markers | |
nmap <silent> <leader>cf <ESC>/\v^[<=>]{7}( .*\|$)<CR> | |
" ,W will delete trailing whitespaces | |
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR> | |
nnoremap <leader>te :tabedit | |
" ruby 1.8 hash style to ruby 1.9 | |
nnoremap <leader>h :%s/:\([^ ]*\)\(\s*\)=>/\1:/gc<CR> | |
" Buffers | |
" | |
set switchbuf="useopen,split" | |
nnoremap <leader>e :e | |
nnoremap <leader>b :b | |
nnoremap <leader>d :bdelete<CR> | |
" buffer switching | |
map <leader><leader> <c-^> | |
map <leader>] :bn<CR> | |
map <leader>[ :bp<CR> | |
map <leader>1 :buffer 1<CR> | |
map <leader>2 :buffer 2<CR> | |
map <leader>3 :buffer 3<CR> | |
map <leader>4 :buffer 4<CR> | |
map <leader>5 :buffer 5<CR> | |
map <leader>6 :buffer 6<CR> | |
map <leader>7 :buffer 7<CR> | |
map <leader>8 :buffer 8<CR> | |
map <leader>9 :buffer 9<CR> | |
nnoremap <leader>a :Ack | |
"fold tag | |
nnoremap <leader>ft Vatzf | |
" 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 | |
" disable cursor keys in normal mode | |
" map <Left> :echo "no!"<cr> | |
" map <Right> :echo "no!"<cr> | |
" map <Up> :echo "no!"<cr> | |
" map <Down> :echo "no!"<cr> | |
" gist | |
let g:gist_clip_command = 'pbcopy' " copy gist into system clipboard | |
let g:gist_detect_filetype = 1 | |
" command-t | |
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> | |
map <leader>f :CommandTFlush<cr>\|:CommandT<cr> | |
" http://vimcasts.org/e/14 | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr> | |
let g:CommandTMaxHeight=10 | |
" supertab | |
let g:SuperTabDefaultCompletionType = '<c-n>' | |
let g:SuperTabContextDefaultCompletionType = '<c-n>' | |
let g:SuperTabLongestHighlight = 1 | |
" Escape special characters in a string for exact matching. | |
" This is useful to copying strings from the file to the search tool | |
" Based on this - http://peterodding.com/code/vim/profile/autoload/xolox/escape.vim | |
function! EscapeString (string) | |
let string=a:string | |
" Escape regex characters | |
let string = escape(string, '^$.*\/~[]') | |
" Escape the line endings | |
let string = substitute(string, '\n', '\\n', 'g') | |
return string | |
endfunction | |
" Get the current visual block for search and replaces | |
" This function passed the visual block through a string escape function | |
" Based on this - http://stackoverflow.com/questions/676600/vim-replace-selected-text/677918#677918 | |
function! GetVisual() range | |
" Save the current register and clipboard | |
let reg_save = getreg('"') | |
let regtype_save = getregtype('"') | |
let cb_save = &clipboard | |
set clipboard& | |
" Put the current visual selection in the " register | |
normal! ""gvy | |
let selection = getreg('"') | |
" Put the saved registers and clipboards back | |
call setreg('"', reg_save, regtype_save) | |
let &clipboard = cb_save | |
"Escape any special characters in the selection | |
let escaped_selection = EscapeString(selection) | |
return escaped_selection | |
endfunction | |
" Start the find and replace command across the entire file | |
" for the visual selection | |
vmap <leader>z <Esc>:%s/<c-r>=GetVisual()<cr>/ | |
" delete trailing spaces automatically on write | |
" autocmd BufWritePre *.rb,*.rake,*.rhtml,*.erb,*.builder,*.js,*.html,*.slim :%s/\s\+$//e | |
" | |
" | |
"solarized | |
" let g:solarized_termcolors=256 | |
colorscheme solarized | |
" press %% to expand the current file path. | |
" Useful to open other files in the same directory | |
cabbr <expr> %% expand('%:p:h') | |
iab dbg require 'debugger' ; debugger | |
"set foldnestmax=3 | |
"set foldmethod=syntax | |
"set foldminlines=3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment