Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created March 14, 2012 23:27
Show Gist options
  • Save dnagir/2040366 to your computer and use it in GitHub Desktop.
Save dnagir/2040366 to your computer and use it in GitHub Desktop.
My current .vimrc
" Example Vim configuration.
" Copy or symlink to ~/.vimrc or ~/_vimrc.
set nocompatible " Must come first because it changes other options.
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
"silent! call pathogen#runtime_append_all_bundles()
syntax enable " Turn on syntax highlighting.
filetype plugin indent on " Turn on file type detection.
runtime macros/matchit.vim " Load the matchit plugin.
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set backspace=indent,eol,start " Intuitive backspacing.
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set visualbell " No beeping.
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set directory=$HOME/.vim/tmp//,. " Keep swap files in one location
" UNCOMMENT TO USE
set tabstop=2 " Global tab width.
set shiftwidth=2 " And again, related.
set expandtab " Use spaces instead of tabs
set softtabstop=2
set mouse=a " Allows to use mouse scrolling
" GRB: clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
set laststatus=2 " Show the status line all the time
" Useful status information at bottom of screen
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{fugitive#statusline()}%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P
" Or use vividchalk
colorscheme vividchalk
:let mapleader = ","
" Tab mappings.
map <leader>tt :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>to :tabonly<cr>
map <leader>tn :tabnext<cr>
map <leader>tp :tabprevious<cr>
map <leader>tf :tabfirst<cr>
map <leader>tl :tablast<cr>
map <leader>tm :tabmove
nmap <leader>, :CommandTBuffer<cr>
nmap <leader>m :MRU<cr>
nmap <leader>q :NERDTree<cr>
" Command-T - allow using ESC
" https://wincent.com/blog/tweaking-command-t-and-vim-for-use-in-the-terminal-and-tmux
if &term =~ "xterm"
let g:CommandTCancelMap = ['<ESC>', '<C-c>']
let g:CommandTSelectNextMap = ['<C-n>', '<C-j>', '<ESC>OB']
let g:CommandTSelectPrevMap = ['<C-p>', '<C-k>', '<ESC>OA']
endif
set wildignore+=.git,.svn,*.o,*.obj,tmp,*swp,*.log,public/system/dragonfly,coverage/
let g:CommandTMaxFiles = 50000 " Scan for more files if within a larger project (def=10000)
map <D-[> :bp<cr>
map <D-]> :bn<cr>
" :bd will close buffer + window
" Using this mapping to keep the window open
" http://stackoverflow.com/questions/1444322/how-can-i-close-a-buffer-without-closing-the-window#answer-5179609
nmap <leader>d :bprevious<CR>:bdelete #<CR>
nmap <leader>w :w<cr>
nmap <leader>a :A<cr>
" INSERT mode mappings.
:imap jj <Esc>
" Commonly used stuff
map <leader>s :w<cr>:! ./script/test %<cr>
" Always enable spellchecking
" disable with `:set nospell` if it gets in your way
:setlocal spell spelllang=en_au
" Controversial...swap colon and semicolon for easier commands
"nnoremap ; :
"nnoremap : ;
"vnoremap ; :
"vnoremap : ;
" Automatic fold settings for specific files. Uncomment to use.
" autocmd FileType ruby setlocal foldmethod=syntax
" autocmd FileType css setlocal foldmethod=indent shiftwidth=2 tabstop=2
" For the MakeGreen plugin and Ruby RSpec. Uncomment to use.
autocmd BufNewFile,BufRead *_spec.rb compiler rspec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment