nowk
3/12/2012 - 3:33 PM

my (ugly) vimrc files

my (ugly) vimrc files

set shell=bash

set nocompatible               " be iMproved
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'

" Load Vunfile
if filereadable(expand('~/.vim/Vunfile'))
  source ~/.vim/Vunfile
endif

filetype plugin indent on     " required! 

" Brief help
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..

" augroup vimrc
"   autocmd!
"   autocmd GuiEnter * set guifont=Anonymous:h11 guioptions-=T columns=120 lines=70 number
" augroup END

" load local vimvrc
if filereadable(expand('~/.vim/vimrc.local'))
  source ~/.vim/vimrc.local
endif
"
syntax on " required!

" -------------------------------------------------------
"
",V reloads it -- making all changes active (have to save first)
map <silent> ,V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>

if has("autocmd")
  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif
endif


if filereadable(expand('~/.vim/config/gui.local'))
  source ~/.vim/config/gui.local
endif


set linespace=2

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

set nobackup
set nowritebackup
set history=1000  " keep 1000 lines of command line history
set ruler         " show the cursor position all the time
set showcmd       " display incomplete commands
set incsearch     " do incremental searching
set clipboard=unnamed " yank to system clipboard


" Spellchecking
set spell

" hide buffers when not displayed
set hidden

" some stuff to get the mouse going in term
set mouse=a
set ttymouse=xterm2
" set selectmode=mouse

" Softtabs, 2 spaces
set ts=2 sts=2 sw=2 expandtab
set autoindent
set smarttab
set smartindent

" code folding
" http://smartic.us/2009/04/06/code-folding-in-vim/
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=1


colorscheme molokai
"colorscheme slate
"colorscheme github


" comments
highlight Comment ctermfg=darkgrey cterm=NONE

" over length
" highlight OverLength ctermbg=darkgrey ctermfg=white
" match OverLength /\%>80v.\+/

" line numbers
set number
highlight LineNr ctermfg=black ctermbg=lightcyan cterm=BOLD

" search highlight
set hlsearch
highlight Search ctermfg=black ctermbg=yellow cterm=NONE

" Hide search highlighting
map <leader>h :set invhls <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>

" line highlight
" hi CursorLine   cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
" hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
" nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>

" statusline
if filereadable(expand('~/.vim/config/statusline.local'))
  source ~/.vim/config/statusline.local
endif


" \ is the leader character
let mapleader = "\\"

" Press Shift+P while in visual mode to replace the selection without
" overwriting the default register
vmap P p :call setreg('"', getreg('0')) <CR>

" Display extra whitespace
set list listchars=tab:»·,trail:·

" e shortcuts
map ,e :e <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,et :tabe <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,es :split <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,ev :vsplit <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>

" additional shortcuts
map ,mkd :!mkdir <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,mv :!mv <C-R>=escape(expand("%"), '\ ')<CR> <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,cp :!cp <C-R>=escape(expand("%"), '\ ')<CR> <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>
map ,sa :saveas <C-R>=escape(expand("%:p:h") . "/", '\ ') <CR>

" Save an run ruby code
" Similar to TM's  cmd+r
map ,r :w !ruby<CR>

" http://robots.thoughtbot.com/post/619330025/viiiiiiiiiiiiiiiiiim
" string and save vai F5
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>:retab<CR>

" Hitting <Control>+h will move the cursor to the beginning of the text on that line and change the first word.
map <silent> <C-h> ^cw

" hitting D will duplicate in selected visual mode
vmap D y'>p

" Plugin settings
"

" FuzzyFinder original
" http://www.vim.org/scripts/script.php?script_id=1984
map <leader>fb :FufBuffer<CR>
map <leader>ff :FufFile<CR>
map <leader>fd :FufDir<CR>
" |:FufMruFile|    " - MRU-File mode (|fuf-mrufile-mode|)
" |:FufMruCmd|     " - MRU-Command mode (|fuf-mrucmd-mode|)
" |:FufBookmark|   " - Bookmark mode (|fuf-bookmark-mode|)
" |:FufTag|        " - Tag mode (|fuf-tag-mode|)
" |:FufTaggedFile| " - Tagged-File mode (|fuf-taggedfile-mode|)
" |:FufJumpList|   " - Jump-List mode (|fuf-jumplist-mode|)
" |:FufChangeList| " - Change-List mode (|fuf-changelist-mode|)
" |:FufQuickfix|   " - Quickfix mode (|fuf-quickfix-mode|)
" |:FufLine|       " - Line mode (|fuf-line-mode|)
" |:FufHelp|       " - Help mode (|fuf-help-mode|)

let g:fuzzy_ignore = "*.svn"
let g:fuzzy_ignore = "*.swp"
let g:fuzzy_ignore = "*~"
let g:fuzzy_ignore = "*.DS_Store"
let g:fuzzy_ignore = "*.git*"

" FuzzyFinderTextmate
map <leader>t :FuzzyFinderTextMate<CR>

" NERDTree
nmap <silent> <leader>p :NERDTreeToggle<CR>
nmap <silent> <leader>b :NERDTreeFromBookmark<CR>

" Ruby Tests
" http://github.com/nowk/vim-rubytest
let g:rubytest_in_quickfix = 0
let g:rubytest_cmd_test          = "ruby -I../test %p"
let g:rubytest_cmd_testcase      = "ruby -I../test %p -n '/%c/'"
" let g:rubytest_cmd_spec          = "bundle exec spec -f specdoc %p"
" let g:rubytest_cmd_spec_example  = "bundle exec spec -f specdoc %p -l '%c'"
let g:rubytest_cmd_spec          = "bundle exec rspec %p"
let g:rubytest_cmd_spec_example  = "bundle exec rspec %p -l '%c'"
let g:rubytest_cmd_feature       = "bundle exec cucumber -r features %"
let g:rubytest_cmd_story         = "bundle exec cucumber -r features % -n '%c'"
map <leader>] <Plug>RubyTestRun
map <leader>} <Plug>RubyFileRun
map <leader>[ <Plug>RubyTestRunLast

" snipMate
ino <s-tab> <c-r>=TriggerSnippet()<cr>
snor <s-tab> <esc>i<right><c-r>=TriggerSnippet()<cr>

" Syntastic
let g:syntastic_enable_signs   = 1
let g:syntastic_auto_loc_list  = 1
let g:syntastic_quiet_warnings = 1
" let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'

" Zenconding
" let g:user_zen_leader_key = '<c-j>'
let g:user_zen_settings = {
\  'indentation' : '  ',
\  'php' : {
\    'extends' : 'html',
\  },
\  'xml' : {
\    'extends' : 'html',
\  },
\  'erb' : {
\    'extends' : 'html',
\  },
\  'haml' : {
\    'extends' : 'html',
\  },
\  'rhtml' : {
\    'extends' : 'html',
\  },
\}

" flog
silent exe "g:flog_enable"
" silent exe "let g:flog_low_color=#a5c261"
" silent exe "let g:flog_medium_color=#ffc66d"
" silent exe "let g:flog_high_color=#cc7833"
" silent exe "let g:flog_background_color=#323232"