""" hanumizzle's .vimrc: 1/\/\ R1<|< ]4/\/\3Z 817<|-| """ vim:foldmethod=marker:textwidth=78 """ Encoding and Internationalisation {{{1 " Vim is not a great editor for Indic scripts. The sundry diacritic " marks common in most of the Brahmic alphabets tend not to line up properly " either in the GUI or with a decent Unicode terminal program. However, it " can't hurt to set a few options here, at least for example. People who edit " Hangeul Korean text may appreciate the benefits of using :set delcombine. In " the context of editing Hangeul, this means that individual letters in a jamo " may be deleted while preserving the rest. I personally find it odd that " elimination of an incorrect maatraa (in Devanagari that is), for example, " means I also want to get rid of the consonant paired with it. " " With all the Indian folks who use Vim, you'd think the mishmash of alphabets " wouldn't be an issue!! " " Vim can also use UTF-8, the single most robust encoding system in the world " for its virtually limitless, unified support for the many scripts of the " world combined with its cleverly pragmatic compatibility with ASCII. Why use " anything else? set encoding=utf-8 " This being the 21st century, I use Unicode set delcombine " Delete combining characters individually """ }}}1 """ Filetype and Syntax {{{1 filetype plugin indent on " Turn on all plugins if &t_Co > 1 || has('gui_running') syntax enable " Syntax highlighting should be on for color terminals endif " Different colorscheme for terminal and GUI alike. Until I find a better " pairing, this stays execute 'colorscheme ' . (has('gui_running') ? 'morning' : 'evening') """ }}}1 """ General Text Editing {{{1 """ Features used regardless the type of file edited, or for broad purposes """ such as 'documentation' and 'programming' in general " All files without a filetype are presumed to be plain text autocmd BufRead,BufNewFile * \ if &filetype == '' | \ setlocal filetype=text | \ endif " Use light indentation and end sentences with a single space when formatting " with gq set tabstop=2 shiftwidth=2 nojoinspaces " Friendlier text editing settings; auto-indentation, narrow (but existent) " margins, and auto-format of paragraphs in addition to recognition of " numbered lists autocmd FileType text \ setlocal autoindent | \ setlocal textwidth=78 | \ setlocal formatoptions+=an set showmatch " Show match for closing member of a natural pair with cursor set matchtime=4 " Jump to matching character briefly (for .4 sec.) " Allow deletion of initial whitespace and characters that came before the " start of the insertion set backspace=indent,start set whichwrap+=h,l " h and l wrap in Normal and Visual mode " Keywords are alpha-numeric characters (possibly including ISO-8859-x " accented characters) are words. Underscores are words. Apostrophes are " words. Anything else is NOT part of a word. autocmd BufReadPost * set iskeyword=A-Z,a-z,160-255,48-57,',_ """ }}}1 """ The Best Programming Language in the Universe {{{1 " The default setting for :set include in Vim is b0rk3n. I suppose I should " report this then. Or you could beat me to the punch and send this fix in " yourself... " " But what /is/ the problem? The default value of include for the Perl " filetype plugin is \\<\\(use\\|require\\)\\>. I supposed this DWIM back in " 2004, when it was last updated, but this is 2005 and it would seem Vim's " backslash-escape parsing is subtly different. There must now be /three/, " count 'em, /three/ backslashes in front of the |; two to produce a literal " \, and one to escape the | itself autocmd FileType perl setlocal include=\\<\\(use\\\|require\\)\\> """ }}}1 """ Mappings {{{1 " Function to execute current line or selected text in Visual mode. ('Adhi' " connotes 'over', 'above', 'upon', 'on', or 'onto' in Sanskrit) " " The whole point of wrapping this up in a function is to take advantage of " visual mode; :call will execute VimAdhiExecute for each line in any visual " selection -- learned it on the official vim@vim.org mailing list from Salman " Halim. Thanks, Salman! function VimAdhiExecute() execute getline('.') endfunction " Handy trick: execute the line under the cursor in Vim scripts autocmd FileType vim map ve :call VimAdhiExecute() " Start a case insensitive search. I usually prefer to do case sensitive " searches, but in a few cases I deviate from that, and IMO it's best to use " /\c, as ':set ic' in the middle of a session is a great inconvenience, and I " sometimes forget it's there, which is an even greater PITA. This is a much " better solution map / /\c """ }}}1 """ Command-Line Editing {{{1 " Unlike most keybindings in Vim, I think the default command line editing " keys suck, and they don't work on my keyboard anyway. Most of the new " bindings correspond to a Vim command in normal mode cnoremap | " Left cursor cnoremap | " Right cursor cnoremap | " Previous element in history cnoremap | " Next element in history cnoremap | " Delete character under cursor cnoremap | " Move forward a word cnoremap | " Move back a word cnoremap | " Delete a word " Turns out I don't like this either " cnoremap | " Delete /all/ text; the analogy is 'C' in Normal mode " cnoremap | " Show *a*ll matches -- mnemonic " Ctrl-L isn't much good for me anyway " cnoremap | " *U*nambiguous match -- mnemonic cnoremap | " Garuda: ^ \__ no logical metaphor available cnoremap | " Vishnu: $ / " }}}1 """ Completion {{{1 " A comprehensive dictionary file culled from OpenOffice's American and " British English dictionaries will be used here. You can get the same " dictionary by changing directory to $OOO_ROOT/share/dict/ooo and doing: " cat en_*.dic | sort | uniq | perl -pnle 's!/.*$!!' set dictionary+=~/.vim/big-dict set complete+=k " Add dictionary search (as per dictionary option) set wildmode=list:full " Argh, why does wildmenu sux0rz? You can't change the keybindings!! Some of " us don't like to use arrow keys! " set wildmenu """ }}}1 """ Session Persistence {{{1 """ History Preservation {{{2 " - Maximum size of a register is 1K " - Likewise, these maximum quantities are 1K: " - Number of lines for each register " - Number of previously edited files which remember marks " - Number of lines in the search pattern, command, and input line " histories " - Convert the encoding if necessary (doubtful) " - Save all marks " - Save the buffer list, excluding nameless and help buffers set viminfo=s1,<1024,'1024,/1024,:1024,@1024,c,f1,%,n~/.viminfo """ }}}2 """ Session Options {{{2 " Keep these items: " - Empty windows " - Buffers, including those not framed in a window " - Folds " - The help window " - Options and mappings, global and local " - Window positions and sizes (internal Vim windows, that is) " - Unix EOL...I refuse to accept that antiquated two-char bunk...we " stopped using TTYs c. C.E. 1970's already! " Also use forward slash in any case. I will of course do my best to avoid " this becoming useful (Suvurnabhumi, being the Pali for 'Land of IT Managers " Whose IQs Soar Well into the Triple Digits') set sessionoptions=blank,buffers,folds,help,options,localoptions,winsize set sessionoptions+=unix,slash " No, just kidding, actually it means 'Land of Gold' " Save the session on exit (at least for GNU screen); I have lines in my " .screenrc that go like so: " screen sh -c 'while true; do vim -S ~/.vim/screen.vim; done' " title v autocmd VimLeave * \ if &term == 'screen' | \ mksession! ~/.vim/screen.vim | \ endif """ }}}2 """ }}}1 """ Backup {{{1 " Backup files and try local .backup directory before $HOME; original file " will be named with an extension of .orig set backup backupdir=./.backup,~/.backup patchmode=.orig " Try to make a .backup directory if possible autocmd BufWritePre * call system('mkdir ' . expand(':p:h') . '/.backup') """ }}}1 """ Folding {{{1 " Define my own damn folding function because the default one grabs chunks of " comments, which is what I don't want. The appearance is otherwise " compatible with the default foldtext() except for minor aesthetics; an " 'astra' (arrow) indicating the fold level precedes the name function MyOwnDamnFoldingFunction() let astra = '>>' . v:folddashes . '> ' " Aww yeah -- make a nice arrow let lines = (v:foldend - v:foldstart + 1) . ' lines: ' " Number of lines let raw = getline(v:foldstart) " The 'raw' fold text " Kill initial whitespace in 'raw', just in case; assign to 'label'. 'label' " is the name distilled from 'raw' let label = substitute(raw, '^\s\+', '', '') " Drag a string consisting of letters, white space, and hyphens out of " label; assign to label let label = matchstr(label, '\(\a\|\s\|-\)\+') " Kill any initial whitespace in *that* as well let label = substitute(label, '^\s\+', '', '') return astra . lines . label endfunction set foldtext=MyOwnDamnFoldingFunction() " Open folds on: " - Horizontal movement upon the fold " - Movement to a mark " - Searches " - Movement to a tag " - Undo (or redo) set foldopen=hor,mark,search,tag,undo " I don't like this, actually. If this is a taste you can acquire, go for it " set foldclose=all " Automatically close folds upon leaving them " " Show a tree diagram on the side indicating fold level and configuration of " folds. Another interesting use for foldcolumn is in GUI when editing text of " any Brahmic variety (that encompasses Gujarati to Cham and everything in " between, not necessarily referring to liturgical text). If a maatraa, tone " mark, what-have-you extends too far to the left, you can simply use " foldcolumn to serve as a margin to make it visible " What I said about i18n usage holds true, but otherwise foldcolumn is " really kind of useless and a little ugly on the side " autocmd FileType vim,perl setlocal foldcolumn=2 " }}}1 """ Status Line {{{1 set laststatus=2 " Always show the status line set ruler " Always show status bar and position in file set showmode " Show the current editing mode at all times set showcmd " Show incomplete commands """ }}}1 """ SVNCommand {{{1 let g:SVNCommandEdit='split' " Split window for edits let g:SVNCommandDeleteOnHide=1 " Kill SVN buffers when hidden " Set buffer-local variables representing revision and branch information for " files under SVN control let g:SVNCommandEnableBufferSetup=1 let g:SVNCommandNameResultBuffers=1 " Name result buffers let g:SVNCommandNameMarker=' o_0 ' " The 'burrito fart in elevator' emoticon " }}}1 """ MiniBufExplorer {{{1 " OK, I'm a sucker for aesthetics; this makes sure that tabs will not be " broken over lines let g:miniBufExplTabWrap = 1 let g:miniBufExplSplitBelow = 0 " MBE displays on top let g:miniBufExplMaxSize = 2 " Prevents the MBE from getting too large " Yeah, that's it. It took a while for someone coming from an Emacs mindset to " accept that a minimum amount of wrangling could produce an effective " configuration """ }}}1 """ File Explorer {{{1 let g:explWinSize=8 " Reduce screen real estate let g:explDetailedList=1 " Show verbose detail by default let g:explHideFiles='^\.' " Hide hidden files -- for a reason!! let g:explFileHandler='MyOwnDamnFileHandler' " The Threefold Path of a programmer being laziness, hubris, and impatience, I " just dispatch all file handling to ROX-Filer. The rest is cribbed from the " example in pl_expl.txt function MyOwnDamnFileHandler(filename) exec "silent! !rox " . escape(a:filename, ' \%#') endfunction """ }}}1 """ Miscellaneous Options {{{1 set incsearch " Incremental search " Neither the title nor the icon options make any sense when using GNU screen, " where the active window may change at any time set notitle noicon set nowrap " Throw this crap out. We hateses it " It turns out that autochdir is only enabled for backwards compatibility with " some kind of Sun IDE, which, as you all probably know, means that it may be " discontinued. What's more, it breaks a *bunch* of scripts with breakitude of " all orders, and I'm tired of going in there and fixing that rubbish. More " like 'Hina 1337'. See 'Remaining Shizzle' for a better solution " set autochdir " Change current directory according to buffer (Maha 1337) set splitbelow " I would rather have split windows below the current window set hidden " Buffers will be hidden when 'abandoned' set shortmess=a " Use abbreviations; don't drop any other verbositude set previewheight=8 " Like File Explorer, preview window height is 8 set visualbell " For the tolerance-impaired among us " set tags+=~/.vim/tags/**/* does NOT work " " It doesn't work when there's more than one match! What the hell is the point " of using wildcards then?? Yargh! So I kludged together a solution using The " Best Programming Language in the Universe instead, which, like Sanskrit, is " capable of doing anything " AddTagFiles needs this...it takes a nominal amount of memory anyway perl use File::Find; " Disya function takes a filetype (supplied by in the following " autocommand) and finds all the tag files under ~/.vim/tags/a:filetype, then " adds them to the tags option function AddTagFiles(filename) " Push all the files in and under ~/.vim/tags/a:filetype onto @mizzle::tags perl find(sub { push @mizzle::tags, $File::Find::name if -f $File::Find::name }, "$ENV{HOME}/.vim/tags/" . +(VIM::Eval('a:filename'))[1]); " Now add each one to tags perl VIM::DoCommand("setlocal tags+=$_") for @mizzle::tags; " Clear out @mizzle::tags perl $#mizzle::tags = -1; endfunction " And here we use it autocmd FileType * call AddTagFiles(expand('')) " The mapleader default sucks. The space bar works better because it is so " broad and therefore an easy staging point for getting all the other keys. " Besides the ergonomic value, no other Vim command uses it :D let g:mapleader=" " let g:maplocalleader=" " " Much of the same. :D " }}}1 """ Remaining Shizzle {{{1 " Load the manual page reading plugin :runtime ftplugin/man.vim " Kill MBE just before writing .viminfo; it buggers up the session autocmd VimLeavePre * \ if (bufnr('-MiniBufExplorer-') != -1) | \ execute 'bwipe ' . bufnr("-MiniBufExplorer-") | \ endif " }}}1