"
" General
"
set nocompatible
"
" Searching
"
set incsearch
set ignorecase
set smartcase
set nohlsearch
"
" Editing
"
set scrolloff=2
set ts=4
filetype plugin indent on
set number
set backupdir=~/.vim/backups
set backup writebackup
syntax enable
"
" Tab navigation
"
map th :tabnext<CR>
map tl :tabprev<CR>
map tn :tabnew<CR>
map td :tabclose<CR>
"
" Path Navigation
"
let g:netrw_keepdir=0
let g:netrw_browse_split=3
"
" Plugins
"
filetype plugin on
" helpful mappings for using twitter.vim
" see http://vim.sourceforge.net/scripts/script.php?script_id=1853
let g:twitterusername='ardekantur'
let g:twitterpassword=''
map tp <Esc>:let g:twitterpassword=inputsecret('Twitter password? ')<cr>
map tw <Esc>:execute 'TwitterStatusUpdate ' . inputdialog('Enter a Twitter status message:')<cr>
map tf <Esc>:TwitterFriendsTimeline<cr>
"
" NERDTree
"
map <F8> :NERDTreeToggle<cr>
"
" Miscellaneous
"
colorscheme Desert-256
"
" Add whitespace
"
map <cr> o<esc>k
"
" Buffer Exploration Shortcuts
"
map <F9> :bn<cr>
map <F10> :bp<cr>
"
" Ruby Indentation Defaults
"
function RubyEndToken ()
let current_line = getline( '.' )
let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
let stuff_without_do = '^\s*\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)'
let with_do = 'do\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
if match(current_line, braces_at_end) >= 0
return "\<CR>}\<C-O>O"
elseif match(current_line, stuff_without_do) >= 0
return "\<CR>end\<C-O>O"
elseif match(current_line, with_do) >= 0
return "\<CR>end\<C-O>O"
else
return "\<CR>"
endif
endfunction
"
function UseRubyIndent ()
setlocal tabstop=8
setlocal softtabstop=2
setlocal shiftwidth=2
setlocal expandtab
imap <buffer> <CR> <C-R>=RubyEndToken()<CR>
endfunction
autocmd FileType ruby,eruby call UseRubyIndent()