Previous Entry Add to Memories Share Next Entry
Geek Alert: Ovid's vimrc
Mechanical
publius_ovidius

Most of you can ignore. Vim fans might see a bit useful stuff here. Basically, I'm putting this up here so I can easily find it no matter which computer I'm at. No, it's not my complete .vimrc. There are a few work-specific items removed.

set nocompatible
set bs=2
set expandtab
set ts=4
set shiftwidth=4
set textwidth=78
set nowrap
set ruler
set autowrite
set hlsearch
set hidden
set autoindent
set fenc=utf8
set incsearch
set showmatch
set smarttab

filetype plugin on

syntax on
colorscheme evening " so we can actually read the darned comments
nohl                " start without highlighting, fer crissakes

noremap ,pt    :%!perltidy -q<cr> " only work in 'normal' mode
noremap ,qq    :%s/(\n\s\+\(qq\?\)\[/(\1[<cr>
noremap ,c     :!perl -Ilib -c %<cr>
noremap ,ca    :!cvs annotate % <bar> less <cr>
noremap ,cl    :!cvs diff % <bar> wc -l <cr>
noremap ,d     :!perl -Ilib -d %<cr>
noremap ,h     :nohl<cr>
noremap ,j     :ls<cr>:e#
noremap ,pd    :!perldoc %<cr>
noremap ,r     :!perl -Ilib %<cr>
noremap ,s     :!subs %<cr>
noremap ,t     :!runtests -lpv -It/lib -It/tests "%"<cr>
noremap ,tc0   :%s/^\v\s*sub\s+\w+[^:]*:.*Tests?\s*(\(\s*(no_plan\|\d+)\s*\))?\s*\{.*$/& ;return;<cr>
noremap ,tc1   :%s/^\v(\s*sub\s+\w+[^:]*:.*Test.*\{.*) ;return;/\1/<cr>
noremap ,tm    ?^sub.*:.*Test<cr>w"zyeOBEGIN { $ENV{TEST_METHOD} = '<c-r>z' }<esc>:nohl<cr>&

vnoremap ,pt   :!perltidy -q<cr>  " only work in 'visual' mode
vnoremap ,qq   :s/(\n\s\+\(qq\?\)\[/(\1[<cr>

" automatically source the .vimrc file if I change it
" the bang (!) forces it to overwrite this command rather than stack it
au! BufWritePost .vimrc source %

noremap ,v  :source ~/.vimrc<cr>
noremap ,V  :e ~/.vimrc<cr>

" make sure the backspace key works
if &term=="xterm"
    " this is a "control-v backspace"
    set t_kb=^?
    fixdel
endif

" make tab autocomplete :) http://www.vim.org/tips/tip.php?tip_id=102
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>

" the following ensures that I cannot commit a file until I've done a quick
" code review
noremap ,cd :call SourceReview()<cr>  " cvs diff
noremap ,cc :call SourceCommit()<cr>  " cvs commit

let g:last_tick = 0
function! SourceReview()
    :!cvs diff % | less
    let g:last_tick = b:changedtick
endfunction

function! SourceCommit()
    if g:last_tick == b:changedtick
        :!EDITOR=/home/cpoe/bin/vim/bin/vim cvs commit %
        let g:last_tick = b:changedtick
    else
        echohl WarningMsg
        echo "You cannot commit source code until you review it"
        echohl None
    endif
endfunction

What makes vim your preferred editor? I'm not trying to start an emacs vs. vim war. I'm just curious, my needs have been so light I just use nano.

I have pretty heavy needs from my editor. I also have a lot of other customizations, including plugins and alternate filetype mappings.

I've no problem with Emacs. I just don't use it.

Some nice ideas to stealbe inspired by there. Cheers.

Cool. Hope you enjoy them! I find that vim can be a fairly decent IDE if used properly.

I took it and laid it down and rolled on it. It is soft and warm. :)

It was also a pretty interesting look at what is possible in the RC file.. I've not looked at the .vimrc recently, but hey my mac's main editor is vim so I grabbed a few of the niftier options. Thanks for the post even though it was simply to satisfy your own needs.

I was gonna post mine, but you can’t post more than 4k in comments here and it’s 10k; and the version on my site is very, very old.

Hmph.