" vimrc, http://sh.kirsle.net/ " Last Modified 2013/09/27 " https://www.mail-archive.com/fish-users@lists.sourceforge.net/msg01425.html if $SHELL =~ 'bin/fish' set shell=/bin/bash endif set encoding=utf8 " Unicode support set nocompatible " use vim defaults set background=dark " my terminal has a black background set tabstop=4 " number of spaces for tab character set softtabstop=4 " insert/delete 4 spaces when hitting a tab/backspace set shiftwidth=4 " number of spaces to auto-indent set shiftround " round indent to multiple of 'shiftwidth' set scrolloff=3 " keep 3 lines when scrolling set smartindent " smart auto-indenting (recognizes C-like code) set showmatch " hilite the matching brace when we type the closing brace set nohls " don't highlight search matches set incsearch " incremental search (search while you type) set ignorecase " case-insensitive search set showcmd " display incomplete commands set ttyfast " smoother changes set autowrite " automatic saving when quitting and switching buffer set autoread " automatic read when file is modified from outside syntax on " syntax highlighting " Leader Key map " When vimrc is edited, reload it. autocmd! BufWritePost .vimrc source ~/.vimrc " Enable filetype plugin filetype plugin on filetype indent on " Mouse support that keeps the fast scroll wheel speed. set mouse=a set ttymouse=xterm2 map 12j map 12k map imap 12j imap 12k imap " Make movement make sense across wrapped lines. nnoremap j gj nnoremap k gk imap gk imap gj map gk map gj " Tell Vim to remember things when we exit: " '10 : marks will be remembered for up to 10 previously edited files " "100 : will save up to 100 lines for each register " :20 : up to 20 lines of command-line history remembered " % : saves and restores the buffer list " n... : where to save the viminfo files set viminfo='10,\"100,:20,%,n~/.viminfo' " Restore the cursor position. function! ResCur() if line("'\"") <= line("$") normal! g`" return 1 endif endfunction augroup resCur autocmd! autocmd BufWinEnter * call ResCur() augroup END " make tab in v mode indent code vmap >gv vmap I nmap ^i " change the bash title so the filename is first in the title bar let &titlestring = expand("%:t") . " - vim on " . hostname() if &term == "screen" set t_ts=k set t_fs=\ endif if &term == "screen" || &term == "xterm" || &term == "xterm-256color" set title endif " custom file extensions au BufNewFile,BufRead *.panel set filetype=html au BufNewFile,BufRead *.tt set filetype=html au BufNewFile,BufRead *.tp set filetype=html " Tab Navigation nnoremap [t :tabprevious nnoremap ]t :tabnext nnoremap [T :tabfirst nnoremap ]T :tablast " Buffer Navigation nnoremap [b :bprev nnoremap ]b :bnext nnoremap [B :bfirst nnoremap ]B :blast """""""""""""""""""""""" """ General coding stuff """""""""""""""""""""""" " git commit messages autocmd Filetype gitcommit setlocal spell textwidth=72 " reStructuredText autocmd FileType rst set tabstop=3 softtabstop=3 shiftwidth=3 expandtab " Make sure the syntax is always right, even when in the middle of " a huge javascript inside an html file. autocmd BufEnter * :syntax sync fromstart " Map F12 to sync the syntax too. noremap :syntax sync fromstart inoremap :syntax sync fromstart " Markdown syntax autocmd BufRead,BufNewFile *.md set ft=markdown " Show tab characters set list listchars=tab:\|\ ,trail:-,extends:>,precedes:<,nbsp:x highlight SpecialKey ctermfg=darkgrey guifg=darkgrey " Show a divider line at the 80 column mark if v:version > 702 set colorcolumn=80,120 highlight ColorColumn ctermbg=darkgrey guibg=darkgrey endif """""""""""""" """ Perl stuff """""""""""""" " check perl code with :make autocmd FileType perl set makeprg=perl\ -c\ %\ $* autocmd FileType perl set errorformat=%f:%l%m " syntax highlight pod documentation correctly let perl_include_pod = 1 " syntax color complex things like @{${"foo"}} let perl_extended_vars = 1 """"""""""""""" """ vim plugins """"""""""""""" " My vim plugins. https://github.com/gmarik/Vundle.vim filetype off " Set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " Layout Plugins Plugin 'scrooloose/nerdtree' Plugin 'jistr/vim-nerdtree-tabs' Plugin 'bling/vim-airline' Plugin 'majutsushi/tagbar' Plugin 'tomasr/molokai' " Editor Enhancements Plugin 'kien/ctrlp.vim' " Languages Plugin 'kchmck/vim-coffee-script' Plugin 'tpope/vim-markdown' Plugin 'editorconfig/editorconfig-vim' call vundle#end() " required filetype plugin indent on " required " Brief help: " :PluginList " :PluginInstall - installs plugins; append '!' to update or :PluginUpdate " :PluginSearch foo - searches for foo; append '!' to refresh local cache " :PluginClean - confirms removal of unused plugins; append '!' " to auto-approve removal " " See :h vundle for more details """"""""""""""""""""""""" """ Plugin Configurations """"""""""""""""""""""""" colorscheme molokai "---------- " NERD Tree "---------- " Auto-open the NERDTree, but focus the original file's panel autocmd VimEnter * NERDTree autocmd VimEnter * wincmd p " The same, but for when you open vim w/o a specific file autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif " map Space-d to show/hide the NERDTree nmap d :NERDTreeToggle " close VIM if the only window left open is the NERDTree autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " NERD Tree Tabs map n NERDTreeTabsToggle "-------- " Airline "-------- " Sexier tab bar let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#buffer_idx_mode = 1 let g:airline#extensions#tabline#tab_nr_mode = 1 nmap 1 AirlineSelectTab1 nmap 2 AirlineSelectTab2 nmap 3 AirlineSelectTab3 nmap 4 AirlineSelectTab4 nmap 5 AirlineSelectTab5 nmap 6 AirlineSelectTab6 nmap 7 AirlineSelectTab7 nmap 8 AirlineSelectTab8 nmap 9 AirlineSelectTab9 "-------- " Tag bar "-------- " F8 to show/hide the tag bar nmap :TagbarToggle "------ " CtrlP "------ let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' "----- " Misc "----- autocmd BufNewFile,BufReadPost *.md set filetype=markdown