set nocompatible set backspace=indent,eol,start set background=dark set matchtime=2 set backup " keep a backup file set backupdir=~/.backup// set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands syntax on set hlsearch set incsearch " Enable file type detection. filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif augroup END set tabstop=2 set sw=2 set expandtab set tags=./tags;~/ " custom filetypes augroup filetypedetect au! BufRead,BufNewFile *.module,*.inc,*.noweb setfiletype php au! BufRead,BufNewFile *.spec setfiletype spec au! BufRead,BufNewFile *.yaml,*.yml setfiletype yaml augroup END " this is the character represented by the meta let mapleader="," " aliases for tabs nnoremap t :tabnew nnoremap > :tabn nnoremap < :tabp " A nicer-looking tabline (vim7 only) if exists(":tabnew") == 2 highlight TabLine term=underline cterm=bold,underline ctermfg=Grey gui=underline highlight TabLineFill term=underline cterm=bold,underline gui=underline guibg=DarkGrey highlight TabLineSel term=reverse cterm=reverse gui=reverse endif " key used to toggle 'paste mode' set pastetoggle= set viminfo='100,f1 " toggle highlighted words from search on/off " map ctrl-n to toggle highlighting nnoremap :set hls! " better search options set ignorecase set smartcase " For filename completion in command mode set wildmode=longest,list " insert some skeleton files on new filetypes augroup templates autocmd BufNewFile *.rb 0r ~/.vim/skeleton.rb | $,$d | normal gg autocmd BufNewFile *.py 0r ~/.vim/skeleton.py | $,$d | normal gg autocmd BufNewFile *.inc 0r ~/.vim/skeleton.inc | $,$d | normal gg autocmd BufNewFile *.php 0r ~/.vim/skeleton.php | $,$d | normal gg autocmd BufNewFile *.sh 0r ~/.vim/skeleton.sh | $,$d | normal gg augroup END " i hate typing this word ab syn synchronize " tab completion let g:no_omni_filetypes = ['php'] function! Tab_Or_Complete() " next entry in popup menu if pumvisible() return "\" endif " if not on whitespace if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$' return "\" elseif count(g:no_omni_filetypes, &filetype) == 0 && exists('&omnifunc') && &omnifunc != '' return "\\" else return "\" endif endfunction inoremap =Tab_Or_Complete() " better complete popup options set completeopt=menu set pumheight=8 " ruby ^_^ let g:rubycomplete_buffer_loading = 1 " bling set statusline=%f\ %m%r%h%w\ %y%=%-14.(%l,%c%V%)\ %P set laststatus=2 " os x clipboard vnoremap y !pbcopyu nnoremap p :read !pbpaste " hooks on php load function! PHP_Filetype() set cindent setlocal makeprg=/usr/bin/env\ php\ -l\ % setlocal errorformat=%m\ in\ %f\ on\ line\ %l endfunction au FileType php call PHP_Filetype() " diff colors highlight DiffChange ctermfg=Gray autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit