Skip to content

Instantly share code, notes, and snippets.

@marcusbaguley
Created May 12, 2011 02:34
Show Gist options
  • Save marcusbaguley/967824 to your computer and use it in GitHub Desktop.
Save marcusbaguley/967824 to your computer and use it in GitHub Desktop.
vim for rails as textmate .vimrc
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set nocompatible
syntax on
filetype plugin indent on
" use softtabs
:set expandtab
:set tabstop=2
:set shiftwidth=2
"Keymappings
let mapleader = ","
:nmap <unique> <silent> <Leader>t :CommandT<CR>
:nmap <unique> <silent> <Leader>b :CommandTBuffer<CR>
:map gc :Rcontroller<CR>
:map gm :Rmodel<CR>
:map gv :Rview<CR>
:map gl :Rlayout<CR>
:map gs :Rspec<CR>
:map gw :Rfind<Space>
:map gec :Rcontroller<Space>
:map gem :Rmodel<Space>
:map gev :Rview<Space>
:map gel :Rlayout<Space>
:map ges :Rspec<Space>
:nmap H 0
:nmap L $
:map <F2> :Rtree<CR>
:map <unique> <Leader>r <Plug>RubyTestRun
:map <unique> <Leader>R <Plug>RubyFileRun
:map <unique> <Leader>l <Plug>RubyTestRunLast
" auto reading/writing
set autoread " auto read externally modified files
set autowrite " write when leaving buffer
set autowriteall " write when leaving buffer (always)
set nobackup " no backup files
autocmd FocusLost * :wa " write on loss of focus (gvim)
autocmd BufLeave,FocusLost * silent! wall
" arrow keys to change window
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
let g:CommandTCancelMap='<C-x>'
" map ctrl-s to save :NOTE set the following in bashrc> stty stop ^- #use 'ctrl -' to replace 'ctrl s'
noremap <silent> <C-S> :update<CR>
vnoremap <silent> <C-S> <C-C>:update<CR>
inoremap <silent> <C-S> <C-O>:update<CR>
" http://items.sjbach.com/319/configuring-vim-right
" The current buffer can be put to the background without writing to disk;
" When a background buffer becomes current again, marks and undo-history are remembered.
" Turn this on.
set hidden
nnoremap ' `
nnoremap ` '
set history=1000
" tab completion in command mode
set wildmode=list:longest
" searching
set ignorecase
set smartcase
set title
" scrolling
set scrolloff=3
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
set ruler
" Intuitive backspacing in insert mode
set backspace=indent,eol,start
" Highlight search terms...
set hlsearch
set incsearch " ...dynamically as they are typed.
" If the search term highlighting gets annoying, set a key to switch it off
" temporarily:
nmap <silent> <leader>n :silent :nohlsearch<CR>
" Ruby test and spork
" http://chirp.syxyz.net/2011/07/spork-with-ruby-1-9-and-testunit/
" http://www.vim.org/scripts/script.php?script_id=2612
let g:rubytest_cmd_test = "testdrb -Itest %p"
let g:rubytest_cmd_testcase = "testdrb -Itest %p -n '/%c/'"
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
command! -complete=file -nargs=* Git call s:ExecuteInShell('git '.<q-args>)
command! -complete=file -nargs=* Bzr call s:ExecuteInShell('bzr '.<q-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment