From ebcfa2eded08423e6f0531fc351b6674a4ae24b5 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Apr 2014 15:20:22 -0400 Subject: Initial commit: .vimrc form 2014.04.20 .vimrc from today. Will be re-adding my plugins as git submodules. --- vimrc | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 348 insertions(+) create mode 100644 vimrc (limited to 'vimrc') diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..20bdf6f --- /dev/null +++ b/vimrc @@ -0,0 +1,348 @@ +" Teddy Wing +" http://www.teddywing.com +" +" 2010.11.06 +" +" CHANGELOG: +" 2014.04.03: +" * Add Shift-Tab mapping to exit Insert mode +" +" 2014.04.11: +" * Preserve indentation on blank lines +" +" 2014.04.12: +" * Add leader and symbols for showing invisible characters +" (http://vimcasts.org/episodes/show-invisibles/) +" * Remove `set expandtab` +" * Add `set softtabstop=4` +" * Add function from Vimcasts to set tab width +" * Add normal mode mapping to toggle expandtab +" * Add [ and ] indentation to retain selection when indenting +" * Add `set hidden` +" * Add `set list` +" * Add soft wrap +" * Source .vimrc whenever it has been saved +" +" 2014.04.15: +" * Add pathogen +" * Add twilight256 colour scheme +" * Add NERD Tree +" * Add Command-T +" * Remap Command-T from t to d +" * Set switchbuf=usetab,newtab +" * Map Control-h to :update +" +" 2014.04.16: +" * Set NERDTree sort order such that all files & directories are sorted +" alphabetically, instead of directories appearing above files. +" * Set NERDTree default width to 24 columns +" * Map j -> gj and k -> gk for moving on wrapped lines +" * Set noendofline +" * Add project-level indentation settings for Flashnotes +" * Remove t mapping because Command-T will not overwrite +" a pre-existing mapping +" * Install TabBar for buffer tabs, add mappings to access tabs using +" commands +" * Map Shift-Tab to Esc in normal mode in addition to Insert & Visual +" * Install commentary.vim and set comment strings for Ruby, JavaScript, +" SCSS, HTML, Python +" +" 2014.04.17: +" * Remove `set :noendofline` as it wasn't doing what I wanted it to do +" * Add & set PreserveNoEOL plugin to preserve file EOL +" * Move commentary.vim autocmds into an augroup +" * Always show status line +" * Make custom status line +" * Change `vb` setting to unabbreviated form, `visualbell` +" * Change 'set' to 'setlocal' in my autocommands +" +" 2014.04.18: +" * Add mappings for easier buffer switching (leader-j, leader-k, +" leader-bx) +" * Use 'a' instead of 'i' in my Control-h save mapping because we want +" to return to the same cursor position +" * Map bl to list buffers +" +" 2014.04.19: +" * Set `timeoutlen` to 500 milliseconds +" +" 2014.04.20: +" * Install EasyGrep plugin and add configuration for EasyGrepCommand=1, +" EasyGrepRecursive=1, EasyGrepEveryMatch=1, +" EasyGrepReplaceAllPerFile=1 +" * Set grepprg=ack +" * Add an extra line of spacing between sections and '===' underlines +" below main headings +" * Move project-specific settings into ~/.vim/projects and source all +" files in that directory +" + + +" Pathogen +" ======== +runtime bundle/vim-pathogen/autoload/pathogen.vim +execute pathogen#infect() +call pathogen#helptags() + + + +" Default configuration +" ===================== +set visualbell t_vb= " Turn off error beep + +set autoindent +set tabstop=4 " Use 4-space tabs +set softtabstop=4 " Allow delete to remove indent when expandtab is enabled +set shiftwidth=4 +" set expandtab + +set wrap " Soft wrap +set linebreak " Don't wrap in the middle of words. Only works when nolist is set + +set scrolloff=3 " Scroll offset: always keep 3 lines + +set showmatch " Highlight matching braces etc. +set hlsearch " Highlight searches +set incsearch " Search for text as you enter it + +set ruler " Show cursor position +set number " Show line numbers + +set list " Show invisibles by default + +set hidden " Don't raise errors when switching buffers with unsaved changes + +" Use tabs for buffers +set switchbuf=usetab,newtab + +set timeoutlen=500 " If bl and b are both mapped, wait 0.5 + " seconds instead of 1 second to fire b if no l + " is pressed subsequently + +set grepprg=ack " Use ack instead of grep + +set laststatus=2 " Always show the status line + +" Statusline +set statusline=%f " Path to file +set statusline+=\ " Separator +set statusline+=%y " Filetype +set statusline+=\ " Separator +set statusline+=%m " File modified? flag +set statusline+=%r " Readonly? flag +set statusline+=\ " Separator +set statusline+=-b%n- " Buffer number as -b{buffer #}- +set statusline+=\ " Separator +set statusline+=%= " Switch to right side +set statusline+=%5l " Line number (ensure space for 5 characters) +set statusline+=, " Comma separator +set statusline+=%-8c " Column number (ensure space for 8 characters) +set statusline+=\ " Separator +set statusline+=%4P " Percent through file in window (ensure space for 4 characters) + + + +" Syntax highlighting (base) +" ========================== +syntax on " Syntax highlighting + +hi Comment ctermfg=green guifg=#919191 cterm=none +hi Constant ctermfg=red guifg=#1C4B80 cterm=none +"hi Identifier +hi Statement ctermfg=blue guifg=#696EC0 +hi PreProc ctermfg=brown guifg=#73371C +hi Type ctermfg=cyan guifg=#696EC0 +hi Special ctermfg=red guifg=#696EC0 +hi Normal ctermfg=black guifg=#dddddd guibg=#09192F + +" Invisible character colours +hi NonText guifg=#4a4a59 +hi SpecialKey guifg=#4a4a59 + +set guifont=Monaco\ 10 + + +" Set Twilight theme +colorscheme twilight256 + + + +" Plugins +" ======= + +" Command-T +" Remap Command-T from t to d (BBEdit style) +nnoremap d :CommandT + + +" NERDTree +" Alphabetical sort ordering +let NERDTreeSortOrder = [] +let NERDTreeWinSize = 24 + +" Toggle NERDTree with leader command +nnoremap f :NERDTreeToggle + + +" TabBar +" j/k to switch to previous/next buffer tab +nnoremap j :Tbbp +nnoremap k :Tbbn + +" Leader+# to switch to a specific buffer tab +nnoremap 1 :TbBfSwitchTo 1: +nnoremap 2 :TbBfSwitchTo 2: +nnoremap 3 :TbBfSwitchTo 3: +nnoremap 4 :TbBfSwitchTo 4: +nnoremap 5 :TbBfSwitchTo 5: +nnoremap 6 :TbBfSwitchTo 6: +nnoremap 7 :TbBfSwitchTo 7: +nnoremap 8 :TbBfSwitchTo 8: +nnoremap 9 :TbBfSwitchTo 9: +nnoremap 0 :TbBfSwitchTo 10: + +inoremap 1 :TbBfSwitchTo 1:a +inoremap 2 :TbBfSwitchTo 2:a +inoremap 3 :TbBfSwitchTo 3:a +inoremap 4 :TbBfSwitchTo 4:a +inoremap 5 :TbBfSwitchTo 5:a +inoremap 6 :TbBfSwitchTo 6:a +inoremap 7 :TbBfSwitchTo 7:a +inoremap 8 :TbBfSwitchTo 8:a +inoremap 9 :TbBfSwitchTo 9:a +inoremap 0 :TbBfSwitchTo 10:a + + +" commentary.vim +augroup commentaryvim + autocmd! + autocmd FileType ruby setlocal commentstring=#\ %s + autocmd FileType html setlocal commentstring= + autocmd FileType javascript setlocal commentstring=//\ %s + autocmd FileType scss setlocal commentstring=//\ %s + autocmd FileType python setlocal commentstring=#\ %s +augroup END + + +" PreserveNoEOL +let g:PreserveNoEOL = 1 + + +" EasyGrep +let g:EasyGrepCommand = 1 " Use grep instead of vimgrep +let g:EasyGrepRecursive = 1 " Recursive search enabled +let g:EasyGrepEveryMatch = 1 " Multiple matches on the same line are distinct +let g:EasyGrepReplaceAllPerFile = 1 + + + +" Mappings +" ======== + +" Shift-Tab to enter normal mode from insert mode +nnoremap +inoremap +vnoremap + +" Control-h to save (Why 'h'? Because it seemed to be a non-important combo +" across modes, and because bash by default doesn't let me map Control-s) +nnoremap :update +inoremap :updatea +vnoremap :updatev + +" Preserve indentation on empty lines +" http://stackoverflow.com/a/7413117 +inoremap x +nnoremap o ox +nnoremap O Ox + +" Show invisibles with i +nnoremap i :set list! + +" Use TextMate-style symbols for tabs and EOLs +set listchars=tab:▸\ ,eol:¬ + +" Toggle between tab and space indentation +nnoremap st :set expandtab! expandtab? + +" OS X-style indentation, retains selection when indenting +" http://vimcasts.org/episodes/indentation-commands/ +nnoremap [ << +nnoremap ] >> +vnoremap [ ] >gv + +" Allow easy moving to wrapped lines +nnoremap j gj +nnoremap k gk + +" Easier buffer switching +nnoremap bl :ls +nnoremap j :bnext +nnoremap k :bprevious + +" Close buffer without closing split +" http://stackoverflow.com/a/4468491 +nnoremap bx :bp \| bd # + + + +" Commands +" ======== + +" Set tabstop, softtabstop and shiftwidth to the same value +" http://vimcasts.org/episodes/tabs-and-spaces/ +command! -nargs=* Stab call Stab() +function! Stab() + let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') + if l:tabstop > 0 + let &l:sts = l:tabstop + let &l:ts = l:tabstop + let &l:sw = l:tabstop + endif + call SummarizeTabs() +endfunction + +function! SummarizeTabs() + try + echohl ModeMsg + echon 'tabstop='.&l:ts + echon ' shiftwidth='.&l:sw + echon ' softtabstop='.&l:sts + if &l:et + echon ' expandtab' + else + echon ' noexpandtab' + endif + finally + echohl None + endtry +endfunction + + +" Swap between soft wrapping and no wrapping +" http://vimcasts.org/episodes/soft-wrapping-text/ +command! -nargs=* Wrap set wrap linebreak nolist + + + +" Autocommands +" ============ + +" Source the vimrc file after saving it +" http://vimcasts.org/episodes/updating-your-vimrc-file-on-the-fly/ +" if has("autocmd") +" autocmd bufwritepost .vimrc source $MYVIMRC +" endif + + + +" Project Settings +" ================ + +" Source all files in the ~/.vim/projects directory +" http://stackoverflow.com/a/4500936 +for f in split(glob('~/.vim/projects/*.vim'), '\n') + execute 'source' f +endfor + -- cgit v1.2.3