- " -----------------------------------------------------------------------------
- " | VIM Settings |
- " | (see gvimrc for gui vim settings) |
- " | |
- " | Some highlights: |
- " | jj = <esc> Very useful for keeping your hands on the home row |
- " | ,n = toggle NERDTree off and on |
- " | |
- " | ,f = fuzzy find all files |
- " | ,b = fuzzy find in all buffers |
- " | |
- " | hh = inserts '=>' |
- " | aa = inserts '@' |
- " | |
- " | ,h = new horizontal window |
- " | ,v = new vertical window |
- " | |
- " | ,i = toggle invisibles |
- " | |
- " | enter and shift-enter = adds a new line after/before the current line |
- " | |
- " | :call Tabstyle_tabs = set tab to real tabs |
- " | :call Tabstyle_spaces = set tab to 2 spaces |
- " | |
- " | Put machine/user specific settings in ~/.vimrc.local |
- " -----------------------------------------------------------------------------
- set nocompatible
- " Tabs ************************************************************************
- "set sta " a <Tab> in an indent inserts 'shiftwidth' spaces
- function! Tabstyle_tabs()
- " Using 4 column tabs
- set softtabstop=4
- set shiftwidth=4
- set tabstop=4
- set noexpandtab
- autocmd User Rails set softtabstop=4
- autocmd User Rails set shiftwidth=4
- autocmd User Rails set tabstop=4
- autocmd User Rails set noexpandtab
- endfunction
- function! Tabstyle_spaces()
- " Use 2 spaces
- set softtabstop=4
- set shiftwidth=4
- set tabstop=4
- set expandtab
- endfunction
- call Tabstyle_spaces()
- " Indenting *******************************************************************
- set ai " Automatically set the indent of a new line (local to buffer)
- set si " smartindent (local to buffer)
- " Scrollbars ******************************************************************
- set sidescrolloff=2
- set numberwidth=4
- " Windows *********************************************************************
- set equalalways " Multiple windows, when created, are equal in size
- set splitbelow splitright
- "Vertical split then hop to new buffer
- :noremap ,v :vsp^M^W^W<cr>
- :noremap ,h :split^M^W^W<cr>
- " Cursor highlights ***********************************************************
- "set cursorline
- "set cursorcolumn
- " Searching *******************************************************************
- set nohlsearch " highlight search
- set incsearch " incremental search, search as you type
- set ignorecase " Ignore case when searching
- set smartcase " Ignore case when searching lowercase
- " Colors **********************************************************************
- "set t_Co=256 " 256 colors
- set background=dark
- syntax on " syntax highlighting
- colorscheme vividchalk
- " Status Line *****************************************************************
- set showcmd
- set ruler " Show ruler
- "set ch=2 " Make command line two lines high
- " Line Wrapping ***************************************************************
- set nowrap
- set linebreak " Wrap at word
- " Mappings ********************************************************************
- " Professor VIM says '87% of users prefer jj over esc', jj abrams disagrees
- imap jj <Esc>
- imap uu _
- imap hh =>
- imap aa @
- " Directories *****************************************************************
- " Setup backup location and enable
- "set backupdir=~/backup/vim
- "set backup
- " Set Swap directory
- "set directory=~/backup/vim/swap
- " Sets path to directory buffer was loaded from
- "autocmd BufEnter * lcd %:p:h
- " File Stuff ******************************************************************
- filetype plugin indent on
- " To show current filetype use: set filetype
- "autocmd FileType html :set filetype=xhtml
- " Inser New Line **************************************************************
- map <S-Enter> O<ESC> " awesome, inserts new line without going into insert mode
- map <Enter> o<ESC>
- set fo-=r " do not insert a comment leader after an enter, (no work, fix!!)
- " Sessions ********************************************************************
- " Sets what is saved when you save a session
- set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
- " Misc ************************************************************************
- set backspace=indent,eol,start
- " set number " Show line numbers
- set matchpairs+=<:>
- set vb t_vb= " Turn off bell, this could be more annoying, but I'm not sure how
- " laptop - blinking cursor no good, lah
- set guicursor+=a:blinkon0
- " Invisible characters *********************************************************
- set listchars=trail:.,tab:>-,eol:$
- set nolist
- :noremap ,i :set list!<CR> " Toggle invisible chars
- " Mouse ***********************************************************************
- "set mouse=a " Enable the mouse
- "behave xterm
- "set selectmode=mouse
- " Cursor Movement *************************************************************
- " Make cursor move by visual lines instead of file lines (when wrapping)
- map <up> gk
- map k gk
- imap <up> <C-o>gk
- map <down> gj
- map j gj
- imap <down> <C-o>gj
- map E ge
- " Ruby stuff ******************************************************************
- "compiler ruby " Enable compiler support for ruby
- "map <F5> :!ruby %<CR>
- " Omni Completion *************************************************************
- autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags
- autocmd FileType python set omnifunc=pythoncomplete#Complete
- autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
- autocmd FileType css set omnifunc=csscomplete#CompleteCSS
- autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
- autocmd FileType php set omnifunc=phpcomplete#CompletePHP
- autocmd FileType c set omnifunc=ccomplete#Complete
- " May require ruby compiled in
- autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
- " -----------------------------------------------------------------------------
- " | Plug-ins |
- " -----------------------------------------------------------------------------
- " NERDTree ********************************************************************
- :noremap ,n :NERDTreeToggle<CR>
- " User instead of Netrw when doing an edit /foobar
- let NERDTreeHijackNetrw=1
- " Single click for everything
- let NERDTreeMouseMode=1
- " SnippetsEmu *****************************************************************
- "imap <unique> <C-j> <Plug>Jumper
- "let g:snip_start_tag = "_\."
- "let g:snip_end_tag = "\._"
- "let g:snip_elem_delim = ":"
- "let g:snip_set_textmate_cp = '1' " Tab to expand snippets, not automatically.
- " fuzzyfinder_textmate ********************************************************
- map ,f :FuzzyFinderTextMate<CR>
- map ,b :FuzzyFinderBuffer<CR>
- "let g:fuzzy_ignore = '.o;.obj;.bak;.exe;.pyc;.pyo;.DS_Store;.db'
- " autocomplpop ***************************************************************
- " complete option
- "set complete=.,w,b,u,t,k
- "let g:AutoComplPop_CompleteOption = '.,w,b,u,t,k'
- "set complete=.
- let g:AutoComplPop_IgnoreCaseOption = 0
- let g:AutoComplPop_BehaviorKeywordLength = 2
- " -----------------------------------------------------------------------------
- " | OS Specific |
- " | (GUI stuff goes in gvimrc) |
- " -----------------------------------------------------------------------------
- " Mac *************************************************************************
- "if has("mac")
- ""
- "endif
- " Windows *********************************************************************
- "if has("gui_win32")
- ""
- "endif
- " -----------------------------------------------------------------------------
- " | Startup |
- " -----------------------------------------------------------------------------
- " Open NERDTree on start
- "autocmd VimEnter * exe 'NERDTree' | wincmd l
- " -----------------------------------------------------------------------------
- " | Host specific |
- " -----------------------------------------------------------------------------
- if filereadable(expand("~/.vimrc.local"))
- source ~/.vimrc.local
- endif
- "if hostname() == "foo"
- " do something
- "endif