Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
272 lines (204 sloc) 6.03 KB
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugin
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e! ~/.vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set smarttab
set lbr
set tw=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the curors - when moving vertical..
set so=7
set wildmenu "Turn on WiLd menu
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hid "Change buffer - without saving
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
set gdefault
map <leader><space> :noh<cr>
nmap <tab> %
vmap <tab> %
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Basic options
set scrolloff=3
set showmode
set showcmd
set hidden
set wildmode=list:longest
set cursorline
set ttyfast
set laststatus=2
set number
set paste
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
" Use the damn hjkl keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
" And make them fucking work, too.
nnoremap j gj
nnoremap k gk
" Easy buffer navigation
map <C-j> <C-w>j
map <C-k> <C-w>k
map <leader>w <C-w>v<C-w>l
" OS cut copy paste
map <leader>c "+y
map <leader>x "+x
map <leader>p "+gp
map <leader>v "+gp
" Clean whitespace
map <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Exuberant ctags!
set tags=tags;/
let Tlist_Ctags_Cmd = "/usr/local/bin/ctags"
let Tlist_WinWidth = 50
map <F4> :TlistToggle<cr>
" Ack
map <leader>a "zyiw:exe "Ack ".@z.""<CR>
" Shouldn't need shift
nnoremap ; :
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" Use the same symbols as TextMate for tabstops and EOLs
set list
"set listchars=tab:▸\ ,eol:¬
set listchars=tab:▸\
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
" Set font according to system
set gfn=Monospace\ 10
set shell=/bin/bash
if has("gui_running")
set guioptions-=T
set t_Co=256
set background=dark
colorscheme desert
set nonu
set guifont=Monospace\ 8
else
colorscheme desert
set background=dark
set nonu
endif
set encoding=utf8
try
lang en_US
catch
endtry
set ffs=unix,dos,mac "Default file types
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
"Persistent undo
try
set undodir=~/.vim/undodir
set undofile
catch
endtry
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
nnoremap <Leader>g :%s/\<<C-r><C-w>\>//g<Left><Left>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Specky
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:speckySpecSwitcherKey = "<C-p>x"
let g:speckyRunSpecKey = "<C-p>s"
let g:speckyWindowType = 2
let g:speckyRunSpecCmd = "/home/ajay/.rvm/rubies/ree-1.8.7-2010.02/bin/ruby /home/ajay/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-1.3.2/bin/spec"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => MiniBuf Explorer
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
set number
set statusline=
set statusline=%F%m%r%h%w\
set statusline+=%{fugitive#statusline()}\
set statusline+=\ [#\ %l\/%L]
set statusline+=%=%2*0x%04B\ %* "character under cursor