Created
February 25, 2013 22:28
-
-
Save theotherzach/5033931 to your computer and use it in GitHub Desktop.
vim setup
packages: pathogen, rails-vim, ruby-vim, ctrlp, vim-commentary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call pathogen#runtime_append_all_bundles() | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" BASIC EDITING CONFIGURATION | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nocompatible | |
" allow unsaved background buffers and remember marks/undo for them | |
set hidden | |
" remember more commands and search history | |
set history=10000 | |
set expandtab | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set autoindent | |
set laststatus=2 | |
set showmatch | |
set incsearch | |
set hlsearch | |
set number | |
" make searches case-sensitive only if they contain upper-case characters | |
set ignorecase smartcase | |
" highlight current line | |
set cursorline | |
set cmdheight=2 | |
set switchbuf=useopen | |
set numberwidth=5 | |
set showtabline=2 | |
set winwidth=79 | |
" This makes RVM work inside Vim. I have no idea why. | |
set shell=bash | |
" Prevent Vim from clobbering the scrollback buffer. See | |
" http://www.shallowsky.com/linux/noaltscreen.html | |
set t_ti= t_te= | |
" keep more context when scrolling off the end of a buffer | |
set scrolloff=3 | |
" Store temporary files in a central spot | |
set backup | |
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
" display incomplete commands | |
set showcmd | |
" Enable highlighting for syntax | |
syntax on | |
filetype plugin indent on | |
" use emacs-style tab completion | |
set wildmode=longest,list | |
" make tab completion for files/ buffers act like bash | |
set wildmenu | |
" fix slow O inserts | |
:set timeout timeoutlen=1000 ttimeoutlen=100 | |
" Ignores long-ass list of node modules | |
set wildignore+=node_modules/** | |
" Status Line | |
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) | |
" Use the system clipboard | |
set clipboard=unnamed "unsure if I like this, may back it out. | |
""""""""""""""""""""" | |
" Misc Map Keys " | |
""""""""""""""""""""" | |
" Map leader to comma. Like everybody else. | |
let mapleader = "," | |
" Use leader leader to re-open last file | |
nnoremap <leader><leader> <c-^> | |
map <leader>y "*y | |
" Insert a hash rocket with <c-l> | |
imap <c-l> <space>=><space> | |
" Can't be bothered to understand ESC vs <c-c> in insert mode | |
imap <c-c> <esc> | |
" Clear the search buffer when hitting return | |
function! MapCR() | |
nnoremap <cr> :nohlsearch<cr> | |
endfunction | |
call MapCR() | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" LISTCHARS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Show bad whitespace | |
if (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8') && version >= 700 | |
let &listchars = "tab:\u21e5\u00b7,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad" | |
let &fillchars = "vert:\u259a,fold:\u00b7" | |
else | |
set listchars=tab:>\ ,trail:-,extends:>,precedes:< | |
endif | |
set list | |
""""""""""""""""""""""""""""""""" | |
" HTML Settings | |
""""""""""""""""""""""""""""""""" | |
let g:html_indent_inctags = "html,body,head,tbody" | |
let g:html_indent_script1 = "inc" | |
let g:html_indent_style1 = "inc" | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" CUSTOM AUTOCMDS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
augroup vimrcEx | |
" Clear all autocmds in the group | |
autocmd! | |
autocmd FileType text setlocal textwidth=78 | |
" Jump to last cursor position unless it's invalid or in an event handler | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
"for ruby, autoindent with two spaces, always expand tabs | |
autocmd FileType ruby,haml,yaml,html,sass,cucumber,javascript set ai sw=2 sts=2 et | |
autocmd FileType python set sw=4 sts=4 et | |
autocmd! BufRead,BufNewFile *.sass setfiletype sass | |
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:> | |
autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:> | |
" Don't syntax highlight markdown because it's often wrong | |
autocmd! FileType mkd setlocal syn=off | |
" Leave the return key alone when in command line windows, since it's used | |
" to run commands there. | |
autocmd! CmdwinEnter * :unmap <cr> | |
autocmd! CmdwinLeave * :call MapCR() | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment