Created
September 15, 2014 19:02
-
-
Save guipdutra/f22e490cd41eabfe11f6 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
"avoiding annoying CSApprox warning message | |
let g:CSApprox_verbose_level = 0 | |
" Required Vundle setup | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Bundle 'gmarik/Vundle.vim' | |
Bundle 'ervandew/supertab' | |
Bundle 'christoomey/vim-tmux-navigator' | |
Bundle 'kien/ctrlp.vim' | |
Bundle 'mattn/gist-vim' | |
Bundle 'mattn/webapi-vim' | |
Bundle 'othree/html5.vim' | |
Bundle 'scrooloose/nerdcommenter' | |
Bundle 'scrooloose/nerdtree' | |
Bundle 'sjl/gundo.vim' | |
Bundle 'tpope/vim-rails' | |
Bundle 'tpope/vim-endwise' | |
Bundle 'tpope/vim-markdown' | |
Bundle 'tpope/vim-ragtag' | |
Bundle 'tpope/vim-surround' | |
Bundle 'SirVer/ultisnips' | |
Bundle 'honza/vim-snippets' | |
Bundle 'terryma/vim-multiple-cursors' | |
Bundle 'jistr/vim-nerdtree-tabs' | |
Bundle 'rainerborene/vim-reek' | |
Bundle 'thoughtbot/vim-rspec' | |
Bundle 'tpope/vim-dispatch' | |
Bundle 'mikewest/vimroom' | |
Bundle 'Keithbsmiley/investigate.vim' | |
Bundle "MarcWeber/vim-addon-mw-utils" | |
Bundle "tomtom/tlib_vim" | |
Bundle "Raimondi/delimitMate" | |
Bundle 'guns/vim-clojure-static' | |
Bundle 'tpope/vim-classpath' | |
Bundle 'tpope/vim-fireplace' | |
"Colors | |
Bundle 'nanotech/jellybeans.vim' | |
call vundle#end() " required | |
filetype plugin indent on " required | |
let g:rspec_command = "Dispatch rspec {spec}" | |
let mapleader = "\<Space>" | |
let delimitMate_expand_cr = 1 | |
autocmd Filetype java set makeprg=javac\ % | |
set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%# | |
map <Leader>ma :make<Return>:copen<Return> | |
" RSpec.vim mappings | |
map <Leader>t :call RunCurrentSpecFile()<CR> | |
map <Leader>l :call RunLastSpec()<CR> | |
map <Leader>a :call RunAllSpecs()<CR> | |
" Trigger configuration. Do not use <tab> if you use | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-z>" | |
" | |
" If you want :UltiSnipsEdit to split your window. | |
let g:UltiSnipsEditSplit="vertical" | |
"allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
"store lots of :cmdline history | |
set history=1000 | |
set showcmd "show incomplete cmds down the bottom | |
set showmode "show current mode down the bottom | |
set incsearch "find the next match as we type the search | |
set hlsearch "hilight searches by default | |
set relativenumber "add line numbers | |
set showbreak=... | |
set wrap linebreak nolist | |
"mapping for command key to map navigation thru display lines instead | |
"of just numbered lines | |
vmap <D-j> gj | |
vmap <D-k> gk | |
vmap <D-4> g$ | |
vmap <D-6> g^ | |
vmap <D-0> g^ | |
nmap <D-j> gj | |
nmap <D-k> gk | |
nmap <D-4> g$ | |
nmap <D-6> g^ | |
nmap <D-0> g^ | |
"add some line space for easy reading | |
set linespace=4 | |
"disable visual bell | |
set visualbell t_vb= | |
"try to make possible to navigate within lines of wrapped lines | |
nmap <Down> gj | |
nmap <Up> gk | |
set fo=l | |
" Fuzzy finder: ignore stuff that can't be opened, and generated files | |
let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**" | |
let g:ackprg = 'ag --nogroup --nocolor --column' | |
"turn off needless toolbar on gvim/mvim | |
set guioptions-=T | |
"turn off the scroll bar | |
set guioptions-=L | |
set guioptions-=r | |
"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() | |
if !exists("b:statusline_trailing_space_warning") | |
if search('\s\+$', 'nw') != 0 | |
let b:statusline_trailing_space_warning = '[\s]' | |
else | |
let b:statusline_trailing_space_warning = '' | |
endif | |
endif | |
return b:statusline_trailing_space_warning | |
endfunction | |
"return the syntax highlight group under the cursor '' | |
function! StatuslineCurrentHighlight() | |
let name = synIDattr(synID(line('.'),col('.'),1),'name') | |
if name == '' | |
return '' | |
else | |
return '[' . name . ']' | |
endif | |
endfunction | |
"recalculate the tab warning flag when idle and after writing | |
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning | |
"return '[&et]' if &et is set wrong | |
"return '[mixed-indenting]' if spaces and tabs are used to indent | |
"return an empty string if everything is fine | |
function! StatuslineTabWarning() | |
if !exists("b:statusline_tab_warning") | |
let tabs = search('^\t', 'nw') != 0 | |
let spaces = search('^ ', 'nw') != 0 | |
if tabs && spaces | |
let b:statusline_tab_warning = '[mixed-indenting]' | |
elseif (spaces && !&et) || (tabs && &et) | |
let b:statusline_tab_warning = '[&et]' | |
else | |
let b:statusline_tab_warning = '' | |
endif | |
endif | |
return b:statusline_tab_warning | |
endfunction | |
"recalculate the long line warning when idle and after saving | |
autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning | |
"return a warning for "long lines" where "long" is either &textwidth or 80 (if | |
"no &textwidth is set) | |
" | |
"return '' if no long lines | |
"return '[#x,my,$z] if long lines are found, were x is the number of long | |
"lines, y is the median length of the long lines and z is the length of the | |
"longest line | |
function! StatuslineLongLineWarning() | |
if !exists("b:statusline_long_line_warning") | |
let long_line_lens = s:LongLines() | |
if len(long_line_lens) > 0 | |
let b:statusline_long_line_warning = "[" . | |
\ '#' . len(long_line_lens) . "," . | |
\ 'm' . s:Median(long_line_lens) . "," . | |
\ '$' . max(long_line_lens) . "]" | |
else | |
let b:statusline_long_line_warning = "" | |
endif | |
endif | |
return b:statusline_long_line_warning | |
endfunction | |
"return a list containing the lengths of the long lines in this buffer | |
function! s:LongLines() | |
let threshold = (&tw ? &tw : 80) | |
let spaces = repeat(" ", &ts) | |
let long_line_lens = [] | |
let i = 1 | |
while i <= line("$") | |
let len = strlen(substitute(getline(i), '\t', spaces, 'g')) | |
if len > threshold | |
call add(long_line_lens, len) | |
endif | |
let i += 1 | |
endwhile | |
return long_line_lens | |
endfunction | |
"find the median of the given array of numbers | |
function! s:Median(nums) | |
let nums = sort(a:nums) | |
let l = len(nums) | |
if l % 2 == 1 | |
let i = (l-1) / 2 | |
return nums[i] | |
else | |
return (nums[l/2] + nums[(l/2)-1]) / 2 | |
endif | |
endfunction | |
"indent settings | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
set autoindent | |
"folding settings | |
set foldmethod=indent "fold based on indent | |
set foldnestmax=3 "deepest fold is 3 levels | |
set nofoldenable "dont fold by default | |
set wildmode=list:longest "make cmdline tab completion similar to bash | |
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches | |
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing | |
"display tabs and trailing spaces | |
"set list | |
"set listchars=tab:\ \ ,extends:>,precedes:< | |
" disabling list because it interferes with soft wrap | |
set formatoptions-=o "dont continue comments when pushing o/O | |
"vertical/horizontal scroll off settings | |
set scrolloff=3 | |
set sidescrolloff=7 | |
set sidescroll=1 | |
"load ftplugins and indent files | |
filetype plugin on | |
filetype indent on | |
"turn on syntax highlighting | |
syntax on | |
"some stuff to get the mouse going in term | |
set mouse=a | |
set ttymouse=xterm2 | |
"hide buffers when not displayed | |
set hidden | |
"Activate smartcase | |
set ic | |
set smartcase | |
if has("gui_running") | |
"tell the term has 256 colors | |
set t_Co=256 | |
colorscheme jellybeans | |
set guitablabel=%M%t | |
set lines=40 | |
set columns=115 | |
if has("gui_gnome") | |
set term=gnome-256color | |
colorscheme jellybeans | |
set guifont=Monospace\ Bold\ 17 | |
endif | |
if has("gui_mac") || has("gui_macvim") | |
set guifont=Menlo:h18 | |
set transparency=7 | |
endif | |
if has("gui_win32") || has("gui_win32s") | |
set guifont=Consolas:h19 | |
set enc=utf-8 | |
endif | |
else | |
"dont load csapprox if there is no gui support - silences an annoying warning | |
let g:CSApprox_loaded = 1 | |
"set jellybeanss colorscheme when running vim in gnome terminal | |
if $COLORTERM == 'gnome-terminal' | |
set term=gnome-256color | |
set t_Co=256 | |
colorscheme jellybeans | |
else | |
if $TERM == 'xterm' | |
set term=xterm-256color | |
colorscheme jellybeans | |
else | |
colorscheme jellybeans | |
endif | |
endif | |
endif | |
" PeepOpen uses <Leader>p as well so you will need to redefine it so something | |
" else in your ~/.vimrc file, such as: | |
" nmap <silent> <Leader>q <Plug>PeepOpen | |
silent! nmap <silent> <Leader>k :NERDTreeToggle<CR> | |
"make <c-l> clear the highlight as well as redraw | |
nnoremap <C-L> :nohls<CR><C-L> | |
inoremap <C-L> <C-O>:nohls<CR> | |
"map to bufexplorer | |
nnoremap <leader>b :BufExplorer<cr> | |
let g:ruby_path = system('rvm current') | |
"map Q to something useful | |
noremap Q gq | |
"make Y consistent with C and D | |
nnoremap Y y$ | |
"bindings for ragtag | |
inoremap <M-o> <Esc>o | |
inoremap <C-j> <Down> | |
let g:ragtag_global_maps = 1 | |
"mark syntax errors with :signs | |
let g:syntastic_enable_signs=1 | |
"key mapping for vimgrep result navigation | |
map <A-o> :copen<CR> | |
map <A-q> :cclose<CR> | |
map <A-j> :cnext<CR> | |
map <A-k> :cprevious<CR> | |
"key mapping for Gundo | |
nnoremap <Leader>gu :GundoToggle<CR> | |
"visual search mappings | |
function! s:VSetSearch() | |
let temp = @@ | |
norm! gvy | |
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') | |
let @@ = temp | |
endfunction | |
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR> | |
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR> | |
"jump to last cursor position when opening a file | |
"dont do it when writing a commit log entry | |
autocmd BufReadPost * call SetCursorPosition() | |
function! SetCursorPosition() | |
if &filetype !~ 'commit\c' | |
if line("'\"") > 0 && line("'\"") <= line("$") | |
exe "normal! g`\"" | |
normal! zz | |
endif | |
end | |
endfunction | |
"define :HighlightLongLines command to highlight the offending parts of | |
"lines that are longer than the specified length (defaulting to 80) | |
command! -nargs=? HighlightLongLines call s:HighlightLongLines('<args>') | |
function! s:HighlightLongLines(width) | |
let targetWidth = a:width != '' ? a:width : 79 | |
if targetWidth > 0 | |
exec 'match Todo /\%>' . (targetWidth) . 'v/' | |
else | |
echomsg "Usage: HighlightLongLines [natural number]" | |
endif | |
endfunction | |
" Strip trailing whitespace | |
function! <SID>StripTrailingWhitespaces() | |
" Preparation: save last search, and cursor position. | |
let _s=@/ | |
let l = line(".") | |
let c = col(".") | |
" Do the business: | |
%s/\s\+$//e | |
" Clean up: restore previous search history, and cursor position | |
let @/=_s | |
call cursor(l, c) | |
endfunction | |
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces() | |
"key mapping for window navigation | |
map <C-h> <C-w>h | |
map <C-j> <C-w>j | |
map <C-k> <C-w>k | |
map <C-l> <C-w>l | |
"key mapping for saving file | |
nmap <c-s> :w<CR> | |
imap <c-s> <Esc>:w<CR>a | |
imap <c-s> <Esc><c-s> | |
"key mapping for tab navigation | |
nmap <Tab> gt | |
nmap <S-Tab> gT | |
"Key mapping for textmate-like indentation | |
nmap <D-[> << | |
nmap <D-]> >> | |
vmap <D-[> <gv | |
vmap <D-]> >gv | |
let ScreenShot = {'Icon':0, 'Credits':0, 'force_background':'#FFFFFF'} | |
"Enabling Zencoding | |
let g:user_zen_settings = { | |
\ 'php' : { | |
\ 'extends' : 'html', | |
\ 'filters' : 'c', | |
\ }, | |
\ 'xml' : { | |
\ 'extends' : 'html', | |
\ }, | |
\ 'haml' : { | |
\ 'extends' : 'html', | |
\ }, | |
\ 'erb' : { | |
\ 'extends' : 'html', | |
\ }, | |
\} | |
" when press { + Enter, the {} block will expand. | |
imap {<CR> {}<ESC>i<CR><ESC>O | |
" NERDTree settings | |
"nmap wo :NERDTree<cr> | |
"nmap wc :NERDTreeClose<cr> | |
let NERDTreeIgnore=['\.swp$'] | |
let g:NERDTreeWinPos = 'left' | |
let g:NERDTreeWinSize = 31 | |
nnoremap <Esc>A <up> | |
nnoremap <Esc>B <down> | |
nnoremap <Esc>C <right> | |
nnoremap <Esc>D <left> | |
inoremap <Esc>A <up> | |
inoremap <Esc>B <down> | |
inoremap <Esc>C <right> | |
inoremap <Esc>D <left> | |
map <Left> <Nop> | |
map <Right> <Nop> | |
map <Up> <Nop> | |
map <Down> <Nop> | |
autocmd vimenter * NERDTreeClose | |
set makeprg=ruby\ % | |
set autowrite | |
map <C-N> :tab split<CR> | |
map <C-X> :x<CR> | |
map <C-F> :find<space> | |
map <C-G> :lopen<CR> | |
map <C-J> :bnext<CR> | |
map <C-K> :bprev<CR> | |
map <C-L> :tabn<CR> | |
map <C-O> :tabe<CR> | |
map <C-H> :tabp<CR> | |
map <C-B> :make<CR> | |
map <F3> :RunSpecLine<cr> | |
map <F2> :RunSpec<cr> | |
map t :A<cr> | |
map cpr :Require<cr> | |
map cpR :Require!<cr> | |
map cpp Require! <cr> :Eval<cr> | |
map <Leader>st :GitStatus<cr> | |
map <Leader>com :!git add . && git commit -m "WIP" <cr> | |
vmap <Leader>b :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR> | |
map <Leader>diff :GitDiff<cr> | |
map <Leader>db :!rake db:migrate<cr> | |
map <Leader>yy ggVG"*y | |
map <Leader>f :Ag<space> | |
map <Leader>on :split notes_about_refactoring.txt<cr> | |
map <Leader>ot :split notes_about_task.txt<cr> | |
map <Leader>m :Rmodel<space> | |
map <Leader>ms :RSmodel<space> | |
map <Leader>mt :RTmodel<space> | |
map <Leader>co :Rcontroller<space> | |
map <Leader>cos :RScontroller<space> | |
map <Leader>cot :RTcontroller<space> | |
map <Leader>lo :RSlocale<space> | |
map <Leader>v :Rview<space> | |
map <Leader>vs :RSview<space> | |
map <Leader>vt :RTview<space> | |
map <Leader>lm :RTmigration<cr> | |
map <Leader>r :Rintegrationtest<space> | |
map <Leader>rs :RSintegrationtest<space> | |
map <Leader>rt :RTintegrationtest<space> | |
map <Leader>g :!zeal --query "<cword>"&<CR><CR> | |
vmap <Leader>z :call I18nTranslateString()<CR> | |
vmap <Leader>y "+y | |
vmap <Leader>d "+d | |
nmap <Leader>p "+p | |
nmap <Leader>P "+P | |
vmap <Leader>p "+p | |
vmap <Leader>P "+P | |
nnoremap <Leader>o :CtrlP<CR> | |
nnoremap <Leader>x :x<CR> | |
nnoremap <Leader>q :q<CR> | |
nnoremap <F5> :set hlsearch!<CR> | |
set shellcmdflag=-ic | |
set noswapfile | |
" Use Silver Searcher instead of grep | |
set grepprg=ag | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" RENAME CURRENT FILE (thanks Gary Bernhardt) | |
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%'), 'file') | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! | |
endif | |
endfunction | |
map <Leader>n :call RenameFile()<cr> | |
" Highlight the status line | |
highlight StatusLine ctermfg=blue ctermbg=yellow | |
set ruler | |
set autoindent | |
set smarttab | |
let g:reek_always_show = 0 | |
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f'] | |
let g:ctrlp_use_caching = 0 | |
" Get rid of the delay when hitting esc! | |
set noesckeys | |
nnoremap <C-y> "+y | |
vnoremap <C-y> "+y | |
nnoremap <C-p> "+gP | |
vnoremap <C-p> "+gP | |
let g:turbux_command_rspec = 'rspec' | |
set nocompatible | |
filetype plugin on | |
syntax on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment