" vim:fdm=marker:ts=4:sw=4:et: " _ " __ _(_)_ __ ___ _ __ ___ " \ \ / / | '_ ` _ \| '__/ __| " \ V /| | | | | | | | | (__ " \_/ |_|_| |_| |_|_| \___| " " Ian's .vimrc file " " Section: Key mappings {{{1 "-------------------------------------------------------------------------- " weird stuff that might confuse other Vim regulars nnoremap ' ` nnoremap ` ' " useful macros I use the most nmap \a :set formatoptions-=a:echo "autowrap disabled" nmap \A :set formatoptions+=a:echo "autowrap enabled" nmap \b :set nocin tw=80:set formatoptions+=a vmap \B :!tabtable nmap \c :%!indent nmap \d :%!perltidy nmap \f :let perl_fold=1:e:set fdl=1 nmap \g mt\d'tzz nmap \h mt\H'tzz nmap \H :%!tidy -icq -asxhtml -w 80 -utf8 nmap \i i> gqapo nmap \I Sgqapo nmap \k :execute "!perl -c %" nmap \l :set number!:set number? nmap \M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4 nmap \m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2 nmap \o :set paste!:set paste? nmap \q :nohlsearch nmap \r mt?^-- $O'tVG{kdOkgqap:nohlsearchO nmap \s :vertical resize 30 nmap \S :vertical resize 60 nmap \t :set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nmap \T :set expandtab tabstop=8 shiftwidth=8 softtabstop=4 nmap \u :set list!:set list? nmap \v :call ToggleMiniBufVerticalness() nmap \w :set wrap!:set wrap? nmap \x :w:%! xmllint --format - nmap \z :w:! nmap \0 :buffers nmap \1 :e #1 nmap \2 :e #2 nmap \3 :e #3 nmap \4 :e #4 nmap \5 :e #5 nmap \6 :e #6 nmap \7 :e #7 nmap \8 :e #8 nmap \9 :e #9 nmap :e# nmap :bnext nmap :bprev nmap :Perldoc " missing emacs-like bindings in insert mode imap $ " emacs-like bindings in command line cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap b cnoremap f cnoremap d " lookup word with meta-D nmap d :!links -dump 'http://www.dict.org/bin/Dict?Form=Dict1&Strategy=*&Database=*&Query=' \| less " CTRL-z is too close, plus I use it very frequently, and i want to write " first if !has('gui_running') nmap - :call WriteAndSuspend() endif function! WriteAndSuspend() if &buftype != 'hidden' && !&readonly if bufname('%') != "" execute 'write' endif endif suspend endfunction " CTRL-p pipes the current buffer to the current filetype as a command " (good for perl, python, ruby, shell, gnuplot...) nmap :call RunUsingCurrentFiletype() nmap p :call RunUsingCurrentFiletype() function! RunUsingCurrentFiletype() execute 'write' execute '! clear; '.&filetype.' <% ' endfunction " Section: Hacks {{{1 "-------------------------------------------------------------------------- " Make j & k linewise {{{2 " turn off linewise keys -- normally, the `j' and `k' keys move the cursor down " one entire line. with line wrapping on, this can cause the cursor to actually " skip a few lines on the screen because it's moving from line N to line N+1 in " the file. I want this to act more visually -- I want `down' to mean the next " line on the screen map j gj map k gk " having Ex mode start or showing me the command history " is a complete pain in the ass if i mistype map Q map q: map K "map q " Keyboard mapping for cursor keys on broken terminals {{{2 " [works for XTerminals - 970818] map [A map [B map [C map [D imap [A imap [B imap [C imap [D " Allow multiple undos when creating a large edited section. {{{2 " http://www.vim.org/tips/tip.php?tip_id=1054 "" function! EnterStuff() "" let theLine = getline(line(".")) "" let pos = col("'^") "" execute "normal mqu\`q" "" if(pos > strlen(theLine)) "" startinsert! "" else "" if(pos > 1) "" normal l "" endif "" startinsert "" endif "" endfunction "" function! ChangeUndoMode(theNum) "" if(a:theNum == 1) "" inoremap ^O^[ "" inoremap :call EnterStuff() "" elseif(a:theNum == 2) "" inoremap ^O^[ "" inoremap ^O^[ "" inoremap ^O^[ "" inoremap :call EnterStuff() "" else "" iunmap "" iunmap "" iunmap "" iunmap "" endif "" endfunction "" call ChangeUndoMode(1) "nmap \sun :call ChangeUndoMode(1) "nmap \gun :call ChangeUndoMode(2) "nmap \bun :call ChangeUndoMode(3) " Section: Abbrevations {{{1 "-------------------------------------------------------------------------- " Vim command line: $c " URL: http://www.vim.org/tips/tip.php?tip_id=1055 cno $c e eCurrentFileDir() function! CurrentFileDir() return "e " . expand("%:p:h") . "/" endfunction " Perl: warnings, strict, use Test::More iab uw; use strict;use warnings; iab ubp; :set paste#!/usr/bin/env perluse strict;use warnings;:set nopaste iab utm; use Test::More 'no_plan';use strict;use warnings; " Section: Vim options {{{1 "-------------------------------------------------------------------------- set autoindent " carry over indenting from previous line set backspace=2 " allow backspace beyond insertion point set cindent " automatic program indenting set cinkeys-=0# " comments don't fiddle with indenting set cino=(0 " indent newlines after opening parenthesis set commentstring=\ \ #%s " when folds are created, add them to this set copyindent " make autoindent use the same chars as prev line set directory-=. " don't store temp files in cwd set encoding=utf8 " UTF-8 by default set expandtab " no tabs set fillchars=vert:\ ,stl:\ ,stlnc:\ ,fold:-,diff:┄ " Unicode chars for diffs/folds, and rely on " colors for window borders set foldmethod=marker " use braces by default set formatoptions=tcqn1 " t - autowrap normal text " c - autowrap comments " q - gq formats comments " n - autowrap lists " 1 - break _before_ single-letter words " 2 - use indenting from 2nd line of para set hidden " don't prompt to save hidden windows until exit set history=200 " how many lines of history to save set hlsearch " hilight searching set ignorecase " case insensitive set incsearch " search as you type set infercase " completion recognizes capitalization set linebreak " break long lines by word, not char set list " show invisble characters in listchars set listchars=tab:▶\ ,trail:◀,extends:»,precedes:« " Unicode characters for various things set matchtime=2 " tenths of second to hilight matching paren set modelines=5 " how many lines of head & tail to look for ml's set mouse=nvc " use the mouse, but not in insert mode set nobackup " no backups left after done editing set novisualbell " no flashing set nowritebackup " no backups made while editing set printoptions=paper:letter " US paper set ruler " show row/col and percentage set scroll=4 " number of lines to scroll with ^U/^D set scrolloff=15 " keep cursor away from this many chars top/bot set shiftround " shift to certain columns, not just n spaces set shiftwidth=4 " number of spaces to shift for autoindent or >,< set showbreak=░ " show for lines that have been wrapped, like Emacs set showmatch " when a bracket is inserted, jump to it set sidescrolloff=3 " keep cursor away from this many chars left/right set smartcase " lets you search for ALL CAPS set softtabstop=4 " spaces 'feel' like tabs set tabstop=4 " the One True Tab set notitle " don't set the title of the Vim window set wildmenu " show possible completions on command line set wildmode=list:longest,full " list all options and complete set wildignore=*.class,*.o,*~ " ignore certain files in tab-completion " enable filetype plugins -- e.g., ftplugin/xml.vim filetype plugin indent on " Section: Commands & Functions {{{1 "-------------------------------------------------------------------------- " i always, ALWAYS hit ":W" instead of ":w" command! Q q command! W w " insert date command! DS r!date " trim spaces at EOL command! TEOL %s/ \+$// command! CLEAN retab | TEOL " hightlight more than 80 characters function! HighlightTooLongLines() highlight def link RightMargin Error if &textwidth != 0 exec 'match RightMargin /\%<' . (&textwidth + 4) . 'v.\%>' . (&textwidth + 2) . 'v/' endif endfunction " Section: Plugin settings {{{1 "-------------------------------------------------------------------------- " for any plugins that use this, make their keymappings use comma let mapleader = "," let maplocalleader = "," " ftplugin/mail.vim let no_plugin_maps = 0 " perl.vim let perl_include_pod = 1 " perldoc let g:perldoc_program='perldoc' " Explore.vim (comes with Vim 6) let explVertical = 1 let explSplitRight = 1 let explWinSize = 30 let explHideFiles = '^\.,\.(class|swp)$,^CVS$' let explDirsFirst = -1 " vtreeexplorer.vim let treeExplVertical = 1 let treeExplWinSize = 30 let treeExplDirSort = -1 unlet! treeExplHidden " vimspell.vim let spell_auto_type = "" " cvscommand.vim let CVSCommandDiffOpt = "" " let .cvsrc handle this " taglist.vim let Tlist_Use_Right_Window = 1 let Tlist_WinWidth = 30 " guifont++.vim let guifontpp_smaller_font_map="" let guifontpp_larger_font_map="" let guifontpp_original_font_map="" " minibufexpl.vim function! ToggleMiniBufVerticalness() let g:miniBufExplVSplit = g:miniBufExplVSplit ? 0 : 40 TMiniBufExplorer TMiniBufExplorer endfunction " Section: Color and syntax {{{1 "-------------------------------------------------------------------------- " make sure colored syntax mode is on if has("terminfo") set t_Co=8 set t_Sf=[3%p1%dm set t_Sb=[4%p1%dm else set t_Co=8 set t_Sf=[3%dm set t_Sb=[4%dm endif syntax on colorscheme default " folded text was too bright - change to black on cyan bg highlight Folded ctermfg=black ctermbg=cyan cterm=none " window splits & ruler were too bright - change to white on grey " (shouldn't change GUI or non-color term appearance) highlight StatusLine cterm=NONE ctermbg=blue ctermfg=white highlight StatusLineNC cterm=NONE ctermbg=black ctermfg=white highlight VertSplit cterm=NONE ctermbg=black ctermfg=white " unfortunately, taglist.vim's filenames is linked to LineNr, which sucks highlight def link MyTagListFileName Statement highlight def link MyTagListTagName Question " turn off coloring for CDATA highlight def link xmlCdata NONE " custom incorrect spelling colors highlight SpellErrors guifg=lightred guibg=bg gui=underline cterm=underline term=underline " ignore should be... ignored highlight Ignore cterm=bold ctermfg=black highlight clear FoldColumn highlight def link FoldColumn Ignore " nice-looking hilight if I remember to set my terminal colors highlight clear Search highlight Search term=NONE cterm=NONE ctermfg=white ctermbg=black " colors for vtreeexplorer highlight treeDir cterm=none ctermfg=blue highlight treeLnk cterm=bold ctermfg=cyan highlight def link treePrt Ignore " make trailing spaces visible highlight SpecialKey ctermbg=Yellow guibg=Yellow " Section: Load ~/.vimlocal {{{1 "-------------------------------------------------------------------------- " now load specifics to this machine source ~/.vimlocal