# HG changeset patch # User Tomas Zeman # Date 1304405821 -7200 # Node ID ca6892f0a9e87417ccd393572554b16e92227e7e # Parent ebfb86eb9718947b55083953c04ce5d43b0d49e5 Imported my .vim dir diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/.VimballRecord --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/.VimballRecord Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,2 @@ +DrawIt.vba: call delete('/home/tomas/.vim/plugin/DrawItPlugin.vim')|call delete('/home/tomas/.vim/plugin/cecutil.vim')|call delete('/home/tomas/.vim/autoload/DrawIt.vim')|call delete('/home/tomas/.vim/doc/DrawIt.txt') +textformat.vba: call delete('/home/tomas/.vim/autoload/textformat.vim')|call delete('/home/tomas/.vim/doc/textformat.txt')|call delete('/home/tomas/.vim/plugin/textformat.vim') diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/autoload/DrawIt.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/autoload/DrawIt.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,1659 @@ +" DrawIt.vim: a simple way to draw things in Vim -- just put this file in +" +" Maintainer: Charles E. Campbell, Jr. (Charles.E.Campbell.1@gsfc.nasa.gov) +" Authors: Charles E. Campbell, Jr. (NdrchipO@ScampbellPfamily.AbizM - NOSPAM) +" Sylvain Viart (molo@multimania.com) +" Version: 8 +" Date: Jul 26, 2007 +" +" Quick Setup: {{{1 +" tar -oxvf DrawIt.tar +" Should put DrawItPlugin.vim in your .vim/plugin directory, +" put DrawIt.vim in your .vim/autoload directory +" put DrawIt.txt in your .vim/doc directory. +" Then, use \di to start DrawIt, +" \ds to stop Drawit, and +" draw by simply moving about using the cursor keys. +" +" You may also use visual-block mode to select endpoints and +" draw lines, arrows, and ellipses. +" +" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" DrawIt.vim is provided *as is* and comes with no warranty +" of any kind, either expressed or implied. By using this +" plugin, you agree that in no event will the copyright +" holder be liable for any damages resulting from the use +" of this software. +" +" Required: THIS SCRIPT REQUIRES VIM 7.0 (or later) {{{1 +" GetLatestVimScripts: 40 1 :AutoInstall: DrawIt.vim +" GetLatestVimScripts: 1066 1 cecutil.vim +" +" Woe to her who is rebellious and polluted, the oppressing {{{1 +" city! She didn't obey the voice. She didn't receive correction. +" She didn't trust in Yahweh. She didn't draw near to her God. (Zeph 3:1,2 WEB) + +" --------------------------------------------------------------------- +" Load Once: {{{1 +if &cp || exists("g:loaded_DrawIt") + finish +endif +let s:keepcpo= &cpo +set cpo&vim + +" --------------------------------------------------------------------- +" Script Variables: {{{1 +if !exists("s:saveposn_count") + let s:saveposn_count= 0 +endif +let g:loaded_DrawIt= "v8" +"DechoTabOn + +" ===================================================================== +" DrawIt Functions: (by Charles E. Campbell, Jr.) {{{1 +" ===================================================================== + +" --------------------------------------------------------------------- +" DrawIt#StartDrawIt: this function maps the cursor keys, sets up default {{{2 +" drawing characters, and makes some settings +fun! DrawIt#StartDrawIt() +" call Dfunc("StartDrawIt()") + + " StartDrawIt: report on [DrawIt] mode {{{3 + if exists("b:dodrawit") && b:dodrawit == 1 + " already in DrawIt mode + echo "[DrawIt] (already on, use ".((exists("mapleader") && mapleader != "")? mapleader : '\')."ds to stop)" +" call Dret("StartDrawIt") + return + endif + let b:dodrawit= 1 + + " indicate in DrawIt mode + echo "[DrawIt]" + + " StartDrawIt: turn on mouse {{{3 + if !exists("b:drawit_keep_mouse") + let b:drawit_keep_mouse= &mouse + endif + setlocal mouse=a + + " StartDrawIt: set up DrawIt commands {{{3 + com! -nargs=1 -range SetBrush ,call DrawIt#SetBrush() + com! -count Canvas call s:Spacer(line("."),line(".") + - 1,0) + + " StartDrawIt: set up default drawing characters {{{3 + if !exists("b:di_vert") + let b:di_vert= "|" + endif + if !exists("b:di_horiz") + let b:di_horiz= "-" + endif + if !exists("b:di_plus") + let b:di_plus= "+" + endif + if !exists("b:di_upright") " also downleft + let b:di_upright= "/" + endif + if !exists("b:di_upleft") " also downright + let b:di_upleft= "\\" + endif + if !exists("b:di_cross") + let b:di_cross= "X" + endif + if !exists("b:di_ellipse") + let b:di_ellipse= '*' + endif + + " set up initial DrawIt behavior (as opposed to erase behavior) + let b:di_erase = 0 + + " StartDrawIt: option recording {{{3 + let b:di_aikeep = &ai + let b:di_cinkeep = &cin + let b:di_cpokeep = &cpo + let b:di_etkeep = &et + let b:di_fokeep = &fo + let b:di_gdkeep = &gd + let b:di_gokeep = &go + let b:di_magickeep = &magic + let b:di_remapkeep = &remap + let b:di_repkeep = &report + let b:di_sikeep = &si + let b:di_stakeep = &sta + let b:di_vekeep = &ve + set cpo&vim + set nocin noai nosi nogd sta et ve=all report=10000 + set go-=aA + set fo-=a + set remap magic + + " StartDrawIt: save and unmap user maps {{{3 + let b:lastdir = 1 + if exists("mapleader") + let usermaplead = mapleader + else + let usermaplead = "\\" + endif + call SaveUserMaps("n","","><^v","DrawIt") + call SaveUserMaps("v",usermaplead,"abeflsy","DrawIt") + call SaveUserMaps("n",usermaplead,"h>","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n","","","DrawIt") + call SaveUserMaps("n",usermaplead,":pa","DrawIt") + call SaveUserMaps("n",usermaplead,":pb","DrawIt") + call SaveUserMaps("n",usermaplead,":pc","DrawIt") + call SaveUserMaps("n",usermaplead,":pd","DrawIt") + call SaveUserMaps("n",usermaplead,":pe","DrawIt") + call SaveUserMaps("n",usermaplead,":pf","DrawIt") + call SaveUserMaps("n",usermaplead,":pg","DrawIt") + call SaveUserMaps("n",usermaplead,":ph","DrawIt") + call SaveUserMaps("n",usermaplead,":pi","DrawIt") + call SaveUserMaps("n",usermaplead,":pj","DrawIt") + call SaveUserMaps("n",usermaplead,":pk","DrawIt") + call SaveUserMaps("n",usermaplead,":pl","DrawIt") + call SaveUserMaps("n",usermaplead,":pm","DrawIt") + call SaveUserMaps("n",usermaplead,":pn","DrawIt") + call SaveUserMaps("n",usermaplead,":po","DrawIt") + call SaveUserMaps("n",usermaplead,":pp","DrawIt") + call SaveUserMaps("n",usermaplead,":pq","DrawIt") + call SaveUserMaps("n",usermaplead,":pr","DrawIt") + call SaveUserMaps("n",usermaplead,":ps","DrawIt") + call SaveUserMaps("n",usermaplead,":pt","DrawIt") + call SaveUserMaps("n",usermaplead,":pu","DrawIt") + call SaveUserMaps("n",usermaplead,":pv","DrawIt") + call SaveUserMaps("n",usermaplead,":pw","DrawIt") + call SaveUserMaps("n",usermaplead,":px","DrawIt") + call SaveUserMaps("n",usermaplead,":py","DrawIt") + call SaveUserMaps("n",usermaplead,":pz","DrawIt") + call SaveUserMaps("n",usermaplead,":ra","DrawIt") + call SaveUserMaps("n",usermaplead,":rb","DrawIt") + call SaveUserMaps("n",usermaplead,":rc","DrawIt") + call SaveUserMaps("n",usermaplead,":rd","DrawIt") + call SaveUserMaps("n",usermaplead,":re","DrawIt") + call SaveUserMaps("n",usermaplead,":rf","DrawIt") + call SaveUserMaps("n",usermaplead,":rg","DrawIt") + call SaveUserMaps("n",usermaplead,":rh","DrawIt") + call SaveUserMaps("n",usermaplead,":ri","DrawIt") + call SaveUserMaps("n",usermaplead,":rj","DrawIt") + call SaveUserMaps("n",usermaplead,":rk","DrawIt") + call SaveUserMaps("n",usermaplead,":rl","DrawIt") + call SaveUserMaps("n",usermaplead,":rm","DrawIt") + call SaveUserMaps("n",usermaplead,":rn","DrawIt") + call SaveUserMaps("n",usermaplead,":ro","DrawIt") + call SaveUserMaps("n",usermaplead,":rp","DrawIt") + call SaveUserMaps("n",usermaplead,":rq","DrawIt") + call SaveUserMaps("n",usermaplead,":rr","DrawIt") + call SaveUserMaps("n",usermaplead,":rs","DrawIt") + call SaveUserMaps("n",usermaplead,":rt","DrawIt") + call SaveUserMaps("n",usermaplead,":ru","DrawIt") + call SaveUserMaps("n",usermaplead,":rv","DrawIt") + call SaveUserMaps("n",usermaplead,":rw","DrawIt") + call SaveUserMaps("n",usermaplead,":rx","DrawIt") + call SaveUserMaps("n",usermaplead,":ry","DrawIt") + call SaveUserMaps("n",usermaplead,":rz","DrawIt") + if exists("g:drawit_insertmode") && g:drawit_insertmode + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + call SaveUserMaps("i","","","DrawIt") + endif + call SaveUserMaps("n","",":\","DrawIt") + + " StartDrawIt: DrawIt maps (Charles Campbell) {{{3 + nmap :set lz:silent! call DrawLeft():set nolz + nmap :set lz:silent! call DrawRight():set nolz + nmap :set lz:silent! call DrawUp():set nolz + nmap :set lz:silent! call DrawDown():set nolz + nmap :set lz:silent! call MoveLeft():set nolz + nmap :set lz:silent! call MoveRight():set nolz + nmap :set lz:silent! call MoveUp():set nolz + nmap :set lz:silent! call MoveDown():set nolz + nmap :set lz:silent! call DrawErase():set nolz + nmap > :set lz:silent! call DrawSpace('>',1):set nolz + nmap < :set lz:silent! call DrawSpace('<',2):set nolz + nmap ^ :set lz:silent! call DrawSpace('^',3):set nolz + nmap v :set lz:silent! call DrawSpace('v',4):set nolz + nmap :set lz:silent! call DrawSlantUpLeft():set nolz + nmap :set lz:silent! call DrawSlantDownLeft():set nolz + nmap :set lz:silent! call DrawSlantUpRight():set nolz + nmap :set lz:silent! call DrawSlantDownRight():set nolz + nmap > :set lz:silent! call DrawFatRArrow():set nolz + nmap < :set lz:silent! call DrawFatLArrow():set nolz + nmap ^ :set lz:silent! call DrawFatUArrow():set nolz + nmap v :set lz:silent! call DrawFatDArrow():set nolz + nmap f :call Flood() + + " StartDrawIt: Set up insertmode maps {{{3 + if exists("g:drawit_insertmode") && g:drawit_insertmode + imap a + imap a + imap a + imap a + imap a + imap a + imap a + imap a + imap a + imap a + imap a + imap a + endif + + " StartDrawIt: set up drawing mode mappings (Sylvain Viart) {{{3 + nnoremap :call LeftStart() + vmap a :call CallBox('Arrow') + vmap b :call CallBox('DrawBox') + nmap c :call Canvas() + vmap l :call CallBox('DrawPlainLine') + vmap s :call Spacer(line("'<"), line("'>"),0) + + " StartDrawIt: set up drawing mode mappings (Charles Campbell) {{{3 + " \pa ... \pz : blanks are transparent + " \ra ... \rz : blanks copy over + vmap e :call CallBox('DrawEllipse') + + let allreg= "abcdefghijklmnopqrstuvwxyz" + while strlen(allreg) > 0 + let ireg= strpart(allreg,0,1) + exe "nmap p".ireg.' :set lz:silent! call PutBlock("'.ireg.'",0):set nolz' + exe "nmap r".ireg.' :set lz:silent! call PutBlock("'.ireg.'",1):set nolz' + let allreg= strpart(allreg,1) + endwhile + + " StartDrawIt: mouse maps (Sylvain Viart) {{{3 + " start visual-block with leftmouse + nnoremap :call LeftStart() + vnoremap :call RightStart(1) + vnoremap :call RightStart(0) + vnoremap :call CLeftStart() + + " StartDrawIt: mouse maps (Charles Campbell) {{{3 + " Draw with current brush + nnoremap :call SLeftStart() + nnoremap :call CLeftStart() + + " StartDrawIt: Menu support {{{3 + if has("gui_running") && has("menu") && &go =~ 'm' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Stop\ \ DrawIt\\ds ds' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Toggle\ Erase\ Mode ' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Arrow\\a a' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Box\\b b' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Make\ Blank\ Zone\\c c' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Ellipse\\e e' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Flood\\e f' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Line\\l l' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Append\ Blanks\\s s' + exe 'silent! unmenu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt' + endif +" call Dret("StartDrawIt") +endfun + +" --------------------------------------------------------------------- +" DrawIt#StopDrawIt: this function unmaps the cursor keys and restores settings {{{2 +fun! DrawIt#StopDrawIt() +" call Dfunc("StopDrawIt()") + + " StopDrawIt: report on [DrawIt off] mode {{{3 + if !exists("b:dodrawit") + echo "[DrawIt off]" +" call Dret("StopDrawIt") + return + endif + + " StopDrawIt: restore mouse {{{3 + if exists("b:drawit_keep_mouse") + let &mouse= b:drawit_keep_mouse + unlet b:drawit_keep_mouse + endif + unlet b:dodrawit + echo "[DrawIt off]" + + if exists("b:drawit_canvas_used") + " StopDrawIt: clean up trailing white space {{{3 + call s:SavePosn() + silent! %s/\s\+$//e + unlet b:drawit_canvas_used + call s:RestorePosn() + endif + + " StopDrawIt: remove drawit commands {{{3 + delc SetBrush + + " StopDrawIt: insure that erase mode is off {{{3 + " (thanks go to Gary Johnson for this) + if b:di_erase == 1 + call s:DrawErase() + endif + + " StopDrawIt: restore user map(s), if any {{{3 + call RestoreUserMaps("DrawIt") + + " StopDrawIt: restore user's options {{{3 + let &ai = b:di_aikeep + let &cin = b:di_cinkeep + let &cpo = b:di_cpokeep + let &et = b:di_etkeep + let &fo = b:di_fokeep + let &gd = b:di_gdkeep + let &go = b:di_gokeep + let &magic = b:di_magickeep + let &remap = b:di_remapkeep + let &report = b:di_repkeep + let &si = b:di_sikeep + let &sta = b:di_stakeep + let &ve = b:di_vekeep + unlet b:di_aikeep + unlet b:di_cinkeep + unlet b:di_cpokeep + unlet b:di_etkeep + unlet b:di_fokeep + unlet b:di_gdkeep + unlet b:di_gokeep + unlet b:di_magickeep + unlet b:di_remapkeep + unlet b:di_repkeep + unlet b:di_sikeep + unlet b:di_stakeep + unlet b:di_vekeep + + " StopDrawIt: DrChip menu support: {{{3 + if has("gui_running") && has("menu") && &go =~ 'm' + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt\\di di' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Stop\ \ DrawIt' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Toggle\ Erase\ Mode' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Arrow' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Box' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Ellipse' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Flood' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Line' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Make\ Blank\ Zone' + exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Append\ Blanks' + endif +" call Dret("StopDrawIt") +endfun + +" --------------------------------------------------------------------- +" SetDrawIt: this function allows one to change the drawing characters {{{2 +fun! SetDrawIt(di_vert,di_horiz,di_plus,di_upleft,di_upright,di_cross,di_ellipse) +" call Dfunc("SetDrawIt(vert<".a:di_vert."> horiz<".a:di_horiz."> plus<".a:di_plus."> upleft<".a:di_upleft."> upright<".a:di_upright."> cross<".a:di_cross."> ellipse<".a:di_ellipse.">)") + let b:di_vert = a:di_vert + let b:di_horiz = a:di_horiz + let b:di_plus = a:di_plus + let b:di_upleft = a:di_upleft + let b:di_upright = a:di_upright + let b:di_cross = a:di_cross + let b:di_ellipse = a:di_ellipse +" call Dret("SetDrawIt") +endfun + +" ===================================================================== +" s:DrawLeft: {{{2 +fun! s:DrawLeft() +" call Dfunc("s:DrawLeft()") + let curline = getline(".") + let curcol = virtcol(".") + let b:lastdir = 2 + + if curcol > 0 + let curchar= strpart(curline,curcol-1,1) + + " replace + if curchar == b:di_vert || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_horiz + endif + + " move and replace + if curcol >= 2 + call s:MoveLeft() + let curchar= strpart(curline,curcol-2,1) + if curchar == b:di_vert || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_horiz + endif + endif + endif +" call Dret("s:DrawLeft") +endfun + +" --------------------------------------------------------------------- +" s:DrawRight: {{{2 +fun! s:DrawRight() +" call Dfunc("s:DrawRight()") + let curline = getline(".") + let curcol = virtcol(".") + let b:lastdir = 1 + + " replace + if curcol == virtcol("$") + exe "norm! a".b:di_horiz."\" + else + let curchar= strpart(curline,curcol-1,1) + if curchar == b:di_vert || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_horiz + endif + endif + + " move and replace + call s:MoveRight() + if curcol == virtcol("$") + exe "norm! i".b:di_horiz."\" + else + let curchar= strpart(curline,curcol,1) + if curchar == b:di_vert || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_horiz + endif + endif +" call Dret("s:DrawRight") +endfun + +" --------------------------------------------------------------------- +" s:DrawUp: {{{2 +fun! s:DrawUp() +" call Dfunc("s:DrawUp()") + let curline = getline(".") + let curcol = virtcol(".") + let b:lastdir = 3 + + " replace + if curcol == 1 && virtcol("$") == 1 + exe "norm! i".b:di_vert."\" + else + let curchar= strpart(curline,curcol-1,1) + if curchar == b:di_horiz || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_vert + endif + endif + + " move and replace/insert + call s:MoveUp() + let curline= getline(".") + let curchar= strpart(curline,curcol-1,1) + + if curcol == 1 && virtcol("$") == 1 + exe "norm! i".b:di_vert."\" + elseif curchar == b:di_horiz || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_vert + endif + endif +" call Dret("s:DrawUp") +endfun + +" --------------------------------------------------------------------- +" s:DrawDown: {{{2 +fun! s:DrawDown() +" call Dfunc("s:DrawDown()") + let curline = getline(".") + let curcol = virtcol(".") + let b:lastdir = 4 + + " replace + if curcol == 1 && virtcol("$") == 1 + exe "norm! i".b:di_vert."\" + else + let curchar= strpart(curline,curcol-1,1) + if curchar == b:di_horiz || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_vert + endif + endif + + " move and replace/insert + call s:MoveDown() + let curline= getline(".") + let curchar= strpart(curline,curcol-1,1) + if curcol == 1 && virtcol("$") == 1 + exe "norm! i".b:di_vert."\" + elseif curchar == b:di_horiz || curchar == b:di_plus + exe "norm! r".b:di_plus + else + exe "norm! r".b:di_vert + endif +" call Dret("s:DrawDown") +endfun + +" --------------------------------------------------------------------- +" s:DrawErase: toggle [DrawIt on] and [DrawIt erase] modes {{{2 +fun! s:DrawErase() +" call Dfunc("s:DrawErase() b:di_erase=".b:di_erase) + if b:di_erase == 0 + let b:di_erase= 1 + echo "[DrawIt erase]" + let b:di_vert_save = b:di_vert + let b:di_horiz_save = b:di_horiz + let b:di_plus_save = b:di_plus + let b:di_upright_save = b:di_upright + let b:di_upleft_save = b:di_upleft + let b:di_cross_save = b:di_cross + call SetDrawIt(' ',' ',' ',' ',' ',' ') + else + let b:di_erase= 0 + echo "[DrawIt]" + call SetDrawIt(b:di_vert_save,b:di_horiz_save,b:di_plus_save,b:di_upleft_save,b:di_upright_save,b:di_cross_save) + endif +" call Dret("s:DrawErase") +endfun + +" --------------------------------------------------------------------- +" s:DrawSpace: clear character and move right {{{2 +fun! s:DrawSpace(chr,dir) +" call Dfunc("s:DrawSpace(chr<".a:chr."> dir<".a:dir.">)") + let curcol= virtcol(".") + + " replace current location with arrowhead/space + if curcol == virtcol("$")-1 + exe "norm! r".a:chr + else + exe "norm! r".a:chr + endif + + if a:dir == 0 + let dir= b:lastdir + else + let dir= a:dir + endif + + " perform specified move + if dir == 1 + call s:MoveRight() + elseif dir == 2 + call s:MoveLeft() + elseif dir == 3 + call s:MoveUp() + else + call s:MoveDown() + endif +" call Dret("s:DrawSpace") +endfun + +" --------------------------------------------------------------------- +" s:DrawSlantDownLeft: / {{{2 +fun! s:DrawSlantDownLeft() +" call Dfunc("s:DrawSlantDownLeft()") + call s:ReplaceDownLeft() " replace + call s:MoveDown() " move + call s:MoveLeft() " move + call s:ReplaceDownLeft() " replace +" call Dret("s:DrawSlantDownLeft") +endfun + +" --------------------------------------------------------------------- +" s:DrawSlantDownRight: \ {{{2 +fun! s:DrawSlantDownRight() +" call Dfunc("s:DrawSlantDownRight()") + call s:ReplaceDownRight() " replace + call s:MoveDown() " move + call s:MoveRight() " move + call s:ReplaceDownRight() " replace +" call Dret("s:DrawSlantDownRight") +endfun + +" --------------------------------------------------------------------- +" s:DrawSlantUpLeft: \ {{{2 +fun! s:DrawSlantUpLeft() +" call Dfunc("s:DrawSlantUpLeft()") + call s:ReplaceDownRight() " replace + call s:MoveUp() " move + call s:MoveLeft() " move + call s:ReplaceDownRight() " replace +" call Dret("s:DrawSlantUpLeft") +endfun + +" --------------------------------------------------------------------- +" s:DrawSlantUpRight: / {{{2 +fun! s:DrawSlantUpRight() +" call Dfunc("s:DrawSlantUpRight()") + call s:ReplaceDownLeft() " replace + call s:MoveUp() " move + call s:MoveRight() " replace + call s:ReplaceDownLeft() " replace +" call Dret("s:DrawSlantUpRight") +endfun + +" --------------------------------------------------------------------- +" s:MoveLeft: {{{2 +fun! s:MoveLeft() +" call Dfunc("s:MoveLeft()") + norm! h + let b:lastdir= 2 +" call Dret("s:MoveLeft : b:lastdir=".b:lastdir) +endfun + +" --------------------------------------------------------------------- +" s:MoveRight: {{{2 +fun! s:MoveRight() +" call Dfunc("s:MoveRight()") + if virtcol(".") >= virtcol("$") - 1 + exe "norm! A \" + else + norm! l + endif + let b:lastdir= 1 +" call Dret("s:MoveRight : b:lastdir=".b:lastdir) +endfun + +" --------------------------------------------------------------------- +" s:MoveUp: {{{2 +fun! s:MoveUp() +" call Dfunc("s:MoveUp()") + if line(".") == 1 + let curcol= virtcol(".") - 1 + if curcol == 0 && virtcol("$") == 1 + exe "norm! i \" + elseif curcol == 0 + exe "norm! YP:s/./ /ge\0r " + else + exe "norm! YP:s/./ /ge\0".curcol."lr " + endif + else + let curcol= virtcol(".") + norm! k + while virtcol("$") <= curcol + exe "norm! A \" + endwhile + endif + let b:lastdir= 3 +" call Dret("s:MoveUp : b:lastdir=".b:lastdir) +endfun + +" --------------------------------------------------------------------- +" s:MoveDown: {{{2 +fun! s:MoveDown() +" call Dfunc("s:MoveDown()") + if line(".") == line("$") + let curcol= virtcol(".") - 1 + if curcol == 0 && virtcol("$") == 1 + exe "norm! i \" + elseif curcol == 0 + exe "norm! Yp:s/./ /ge\0r " + else + exe "norm! Yp:s/./ /ge\0".curcol."lr " + endif + else + let curcol= virtcol(".") + norm! j + while virtcol("$") <= curcol + exe "norm! A \" + endwhile + endif + let b:lastdir= 4 +" call Dret("s:MoveDown : b:lastdir=".b:lastdir) +endfun + +" --------------------------------------------------------------------- +" s:ReplaceDownLeft: / X (upright) {{{2 +fun! s:ReplaceDownLeft() +" call Dfunc("s:ReplaceDownLeft()") + let curcol = virtcol(".") + if curcol != virtcol("$") + let curchar= strpart(getline("."),curcol-1,1) + if curchar == "\\" || curchar == "X" + exe "norm! r".b:di_cross + else + exe "norm! r".b:di_upright + endif + else + exe "norm! i".b:di_upright."\" + endif +" call Dret("s:ReplaceDownLeft") +endfun + +" --------------------------------------------------------------------- +" s:ReplaceDownRight: \ X (upleft) {{{2 +fun! s:ReplaceDownRight() +" call Dfunc("s:ReplaceDownRight()") + let curcol = virtcol(".") + if curcol != virtcol("$") + let curchar= strpart(getline("."),curcol-1,1) + if curchar == "/" || curchar == "X" + exe "norm! r".b:di_cross + else + exe "norm! r".b:di_upleft + endif + else + exe "norm! i".b:di_upleft."\" + endif +" call Dret("s:ReplaceDownRight") +endfun + +" --------------------------------------------------------------------- +" s:DrawFatRArrow: ----|> {{{2 +fun! s:DrawFatRArrow() +" call Dfunc("s:DrawFatRArrow()") + call s:MoveRight() + norm! r| + call s:MoveRight() + norm! r> +" call Dret("s:DrawFatRArrow") +endfun + +" --------------------------------------------------------------------- +" s:DrawFatLArrow: <|---- {{{2 +fun! s:DrawFatLArrow() +" call Dfunc("s:DrawFatLArrow()") + call s:MoveLeft() + norm! r| + call s:MoveLeft() + norm! r< +" call Dret("s:DrawFatLArrow") +endfun + +" --------------------------------------------------------------------- +" . +" s:DrawFatUArrow: /_\ {{{2 +" | +fun! s:DrawFatUArrow() +" call Dfunc("s:DrawFatUArrow()") + call s:MoveUp() + norm! r_ + call s:MoveRight() + norm! r\ + call s:MoveLeft() + call s:MoveLeft() + norm! r/ + call s:MoveRight() + call s:MoveUp() + norm! r. +" call Dret("s:DrawFatUArrow") +endfun + +" --------------------------------------------------------------------- +" s:DrawFatDArrow: _|_ {{{2 +" \ / +" ' +fun! s:DrawFatDArrow() +" call Dfunc("s:DrawFatDArrow()") + call s:MoveRight() + norm! r_ + call s:MoveLeft() + call s:MoveLeft() + norm! r_ + call s:MoveDown() + norm! r\ + call s:MoveRight() + call s:MoveRight() + norm! r/ + call s:MoveDown() + call s:MoveLeft() + norm! r' +" call Dret("s:DrawFatDArrow") +endfun + +" --------------------------------------------------------------------- +" s:DrawEllipse: Bresenham-like ellipse drawing algorithm {{{2 +" 2 2 can +" x y be 2 2 2 2 2 2 +" - + - = 1 rewritten b x + a y = a b +" a b as +" +" Take step which has minimum error +" (x,y-1) (x+1,y) (x+1,y-1) +" +" 2 2 2 2 2 2 +" Ei = | b x + a y - a b | +" +" Algorithm only draws arc from (0,b) to (a,0) and uses +" DrawFour() to reflect points to other three quadrants +fun! s:DrawEllipse(x0,y0,x1,y1) +" call Dfunc("s:DrawEllipse(x0=".a:x0." y0=".a:y0." x1=".a:x1." y1=".a:y1.")") + let x0 = a:x0 + let y0 = a:y0 + let x1 = a:x1 + let y1 = a:y1 + let xoff = (x0+x1)/2 + let yoff = (y0+y1)/2 + let a = s:Abs(x1-x0)/2 + let b = s:Abs(y1-y0)/2 + let a2 = a*a + let b2 = b*b + let twoa2= a2 + a2 + let twob2= b2 + b2 + + let xi= 0 + let yi= b + let ei= 0 + call s:DrawFour(xi,yi,xoff,yoff,a,b) + while xi <= a && yi >= 0 + + let dy= a2 - twoa2*yi + let ca= ei + twob2*xi + b2 + let cb= ca + dy + let cc= ei + dy + + let aca= s:Abs(ca) + let acb= s:Abs(cb) + let acc= s:Abs(cc) + + " pick case: (xi+1,yi) (xi,yi-1) (xi+1,yi-1) + if aca <= acb && aca <= acc + let xi= xi + 1 + let ei= ca + elseif acb <= aca && acb <= acc + let ei= cb + let xi= xi + 1 + let yi= yi - 1 + else + let ei= cc + let yi= yi - 1 + endif + if xi > a:x1 + break + endif + call s:DrawFour(xi,yi,xoff,yoff,a,b) + endw +" call Dret("s:DrawEllipse") +endf + +" --------------------------------------------------------------------- +" s:DrawFour: reflect a point to four quadrants {{{2 +fun! s:DrawFour(x,y,xoff,yoff,a,b) +" call Dfunc("s:DrawFour(xy[".a:x.",".a:y."] off[".a:xoff.",".a:yoff."] a=".a:a." b=".a:b.")") + let x = a:xoff + a:x + let y = a:yoff + a:y + let lx = a:xoff - a:x + let by = a:yoff - a:y + call s:SetCharAt(b:di_ellipse, x, y) + call s:SetCharAt(b:di_ellipse, lx, y) + call s:SetCharAt(b:di_ellipse, lx,by) + call s:SetCharAt(b:di_ellipse, x,by) +" call Dret("s:DrawFour") +endf + +" --------------------------------------------------------------------- +" s:SavePosn: saves position of cursor on screen so NetWrite can restore it {{{2 +fun! s:SavePosn() +" call Dfunc("s:SavePosn() saveposn_count=".s:saveposn_count.' ['.line('.').','.virtcol('.').']') + let s:saveposn_count= s:saveposn_count + 1 + + " Save current line and column + let b:drawit_line_{s:saveposn_count} = line(".") + let b:drawit_col_{s:saveposn_count} = virtcol(".") - 1 + + " Save top-of-screen line + norm! H + let b:drawit_hline_{s:saveposn_count}= line(".") + + " restore position + exe "norm! ".b:drawit_hline_{s:saveposn_count}."G0z\" + if b:drawit_col_{s:saveposn_count} == 0 + exe "norm! ".b:drawit_line_{s:saveposn_count}."G0" + else + exe "norm! ".b:drawit_line_{s:saveposn_count}."G0".b:drawit_col_{s:saveposn_count}."l" + endif +" call Dret("s:SavePosn : saveposn_count=".s:saveposn_count) +endfun + +" ------------------------------------------------------------------------ +" s:RestorePosn: {{{2 +fun! s:RestorePosn() +" call Dfunc("s:RestorePosn() saveposn_count=".s:saveposn_count) + if s:saveposn_count <= 0 +" call Dret("s:RestorePosn : s:saveposn_count<=0") + return + endif + " restore top-of-screen line + exe "norm! ".b:drawit_hline_{s:saveposn_count}."G0z\" + + " restore position + if b:drawit_col_{s:saveposn_count} == 0 + exe "norm! ".b:drawit_line_{s:saveposn_count}."G0" + else + exe "norm! ".b:drawit_line_{s:saveposn_count}."G0".b:drawit_col_{s:saveposn_count}."l" + endif + if s:saveposn_count > 0 + unlet b:drawit_hline_{s:saveposn_count} + unlet b:drawit_line_{s:saveposn_count} + unlet b:drawit_col_{s:saveposn_count} + let s:saveposn_count= s:saveposn_count - 1 + endif +" call Dret("s:RestorePosn : saveposn_count=".s:saveposn_count) +endfun + +" ------------------------------------------------------------------------ +" s:Flood: this function begins a flood of a region {{{2 +" based on b:di... characters as boundaries +" and starting at the current cursor location. +fun! s:Flood() +" call Dfunc("s:Flood()") + + let s:bndry = b:di_vert.b:di_horiz.b:di_plus.b:di_upright.b:di_upleft.b:di_cross.b:di_ellipse + let row = line(".") + let col = virtcol(".") + let athold = @0 + let s:DIrows = line("$") + call s:SavePosn() + + " get fill character from user + " Put entire fillchar string into the s:bndry (boundary characters), + " although only use the first such character for filling + call inputsave() + let s:fillchar= input("Enter fill character: ") + call inputrestore() + let s:bndry= "[".escape(s:bndry.s:fillchar,'\-]^')."]" + if strlen(s:fillchar) > 1 + let s:fillchar= strpart(s:fillchar,0,1) + endif + + " flood the region + call s:DI_Flood(row,col) + + " restore + call s:RestorePosn() + let @0= athold + unlet s:DIrows s:bndry s:fillchar + +" call Dret("s:Flood") +endfun + +" ------------------------------------------------------------------------ +" s:DI_Flood: fill up to the boundaries all characters to the left and right. {{{2 +" Then, based on the left/right column extents reached, check +" adjacent rows to see if any characters there need filling. +fun! s:DI_Flood(frow,fcol) +" call Dfunc("s:DI_Flood(frow=".a:frow." fcol=".a:fcol.")") + if a:frow <= 0 || a:fcol <= 0 || s:SetPosn(a:frow,a:fcol) || s:IsBoundary(a:frow,a:fcol) +" call Dret("s:DI_Flood") + return + endif + + " fill current line + let colL= s:DI_FillLeft(a:frow,a:fcol) + let colR= s:DI_FillRight(a:frow,a:fcol+1) + + " do a filladjacent on the next line up + if a:frow > 1 + call s:DI_FillAdjacent(a:frow-1,colL,colR) + endif + + " do a filladjacent on the next line down + if a:frow < s:DIrows + call s:DI_FillAdjacent(a:frow+1,colL,colR) + endif + +" call Dret("s:DI_Flood") +endfun + +" ------------------------------------------------------------------------ +" s:DI_FillLeft: Starting at (frow,fcol), non-boundary locations are {{{2 +" filled with the fillchar. The leftmost extent reached +" is returned. +fun! s:DI_FillLeft(frow,fcol) +" call Dfunc("s:DI_FillLeft(frow=".a:frow." fcol=".a:fcol.")") + if s:SetPosn(a:frow,a:fcol) +" call Dret("s:DI_FillLeft ".a:fcol) + return a:fcol + endif + + let Lcol= a:fcol + while Lcol >= 1 + if !s:IsBoundary(a:frow,Lcol) + exe "silent! norm! r".s:fillchar."h" + else + break + endif + let Lcol= Lcol - 1 + endwhile + + let Lcol= (Lcol < 1)? 1 : Lcol + 1 + +" call Dret("s:DI_FillLeft ".Lcol) + return Lcol +endfun + +" --------------------------------------------------------------------- +" s:DI_FillRight: Starting at (frow,fcol), non-boundary locations are {{{2 +" filled with the fillchar. The rightmost extent reached +" is returned. +fun! s:DI_FillRight(frow,fcol) +" call Dfunc("s:DI_FillRight(frow=".a:frow." fcol=".a:fcol.")") + if s:SetPosn(a:frow,a:fcol) +" call Dret("s:DI_FillRight ".a:fcol) + return a:fcol + endif + + let Rcol = a:fcol + while Rcol <= virtcol("$") + if !s:IsBoundary(a:frow,Rcol) + exe "silent! norm! r".s:fillchar."l" + else + break + endif + let Rcol= Rcol + 1 + endwhile + + let DIcols = virtcol("$") + let Rcol = (Rcol > DIcols)? DIcols : Rcol - 1 + +" call Dret("s:DI_FillRight ".Rcol) + return Rcol +endfun + +" --------------------------------------------------------------------- +" s:DI_FillAdjacent: {{{2 +" DI_Flood does FillLeft and FillRight, so the run from left to right +" (fcolL to fcolR) is known to have been filled. FillAdjacent is called +" from (fcolL to fcolR) on the lines one row up and down; if any character +" on the run is not a boundary character, then a flood is needed on that +" location. +fun! s:DI_FillAdjacent(frow,fcolL,fcolR) +" call Dfunc("s:DI_FillAdjacent(frow=".a:frow." fcolL=".a:fcolL." fcolR=".a:fcolR.")") + + let icol = a:fcolL + while icol <= a:fcolR + if !s:IsBoundary(a:frow,icol) + call s:DI_Flood(a:frow,icol) + endif + let icol= icol + 1 + endwhile + +" call Dret("s:DI_FillAdjacent") +endfun + +" --------------------------------------------------------------------- +" s:SetPosn: set cursor to given position on screen {{{2 +" srow,scol: -s-creen row and column +" Returns 1 : failed sanity check +" 0 : otherwise +fun! s:SetPosn(row,col) +" call Dfunc("s:SetPosn(row=".a:row." col=".a:col.")") + " sanity checks + if a:row < 1 +" call Dret("s:SetPosn 1") + return 1 + endif + if a:col < 1 +" call Dret("s:SetPosn 1") + return 1 + endif + + exe "norm! ".a:row."G".a:col."\" + +" call Dret("s:SetPosn 0") + return 0 +endfun + +" --------------------------------------------------------------------- +" s:IsBoundary: returns 0 if not on boundary, 1 if on boundary {{{2 +" The "boundary" also includes the fill character. +fun! s:IsBoundary(row,col) +" call Dfunc("s:IsBoundary(row=".a:row." col=".a:col.")") + + let orow= line(".") + let ocol= virtcol(".") + exe "norm! ".a:row."G".a:col."\" + norm! vy + let ret= @0 =~ s:bndry + if a:row != orow || a:col != ocol + exe "norm! ".orow."G".ocol."\" + endif + +" call Dret("s:IsBoundary ".ret." : @0<".@0.">") + return ret +endfun + +" --------------------------------------------------------------------- +" s:PutBlock: puts a register's contents into the text at the current {{{2 +" cursor location +" replace= 0: Blanks are transparent +" = 1: Blanks copy over +" = 2: Erase all drawing characters +" +fun! s:PutBlock(block,replace) +" call Dfunc("s:PutBlock(block<".a:block."> replace=".a:replace.")") + call s:SavePosn() + exe "let block = @".a:block + let blocklen = strlen(block) + let drawit_line = line('.') + let drawchars = '['.escape(b:di_vert.b:di_horiz.b:di_plus.b:di_upright.b:di_upleft.b:di_cross,'\-').']' + + " insure that putting a block will do so in a region containing spaces out to textwidth + exe "let blockrows= strlen(substitute(@".a:block.",'[^[:cntrl:]]','','g'))" + exe 'let blockcols= strlen(substitute(@'.a:block.",'^\\(.\\{-}\\)\\n\\_.*$','\\1',''))" + let curline= line('.') + let curcol = virtcol('.') +" call Decho("blockrows=".blockrows." blockcols=".blockcols." curline=".curline." curcol=".curcol) + call s:AutoCanvas(curline-1,curline + blockrows+1,curcol + blockcols) + + let iblock = 0 + while iblock < blocklen + let chr= strpart(block,iblock,1) + + if char2nr(chr) == 10 + " handle newline + let drawit_line= drawit_line + 1 + if b:drawit_col_{s:saveposn_count} == 0 + exe "norm! ".drawit_line."G0" + else + exe "norm! ".drawit_line."G0".b:drawit_col_{s:saveposn_count}."l" + endif + + elseif a:replace == 2 + " replace all drawing characters with blanks + if match(chr,drawchars) != -1 + norm! r l + else + norm! l + endif + + elseif chr == ' ' && a:replace == 0 + " allow blanks to be transparent + norm! l + + else + " usual replace character + exe "norm! r".chr."l" + endif + let iblock = iblock + 1 + endwhile + call s:RestorePosn() + +" call Dret("s:PutBlock") +endfun + +" --------------------------------------------------------------------- +" s:AutoCanvas: automatic "Canvas" routine {{{2 +fun! s:AutoCanvas(linestart,linestop,cols) +" call Dfunc("s:AutoCanvas(linestart=".a:linestart." linestop=".a:linestop." cols=".a:cols.") line($)=".line("$")) + + " insure there's enough blank lines at end-of-file + if line("$") < a:linestop +" call Decho("append ".(a:linestop - line("$"))." empty lines") + call s:SavePosn() + exe "norm! G".(a:linestop - line("$"))."o\" + call s:RestorePosn() + endif + + " insure that any tabs contained within the selected region are converted to blanks + let etkeep= &et + set et +" call Decho("exe ".a:linestart.",".a:linestop."retab") + exe a:linestart.",".a:linestop."retab" + let &et= etkeep + + " insure that there's whitespace to textwidth/screenwidth/a:cols + if a:cols <= 0 + let tw= &tw + if tw <= 0 + let tw= &columns + endif + else + let tw= a:cols + endif +" Decho("tw=".tw) + if search('^$\|.\%<'.(tw+1).'v$',"cn",(a:linestop+1)) > 0 +" call Decho("append trailing whitespace") + call s:Spacer(a:linestart,a:linestop,tw) + endif + +" call Dret("s:AutoCanvas : tw=".tw) +endfun + +" ===================================================================== +" DrawIt Functions: (by Sylvain Viart) {{{1 +" ===================================================================== + +" --------------------------------------------------------------------- +" s:Canvas: {{{2 +fun! s:Canvas() +" call Dfunc("s:Canvas()") + + let lines = input("how many lines under the cursor? ") + let curline= line('.') + if curline < line('$') + exe "norm! ".lines."o\" + endif + call s:Spacer(curline+1,curline+lines,0) + let b:drawit_canvas_used= 1 + +" call Dret("s:Canvas") +endf + +" --------------------------------------------------------------------- +" s:Spacer: fill end of line with space {{{2 +" if a:cols >0: to the virtual column specified by a:cols +" <=0: to textwidth (if nonzero), otherwise +" to display width (&columns) +fun! s:Spacer(debut, fin, cols) range +" call Dfunc("s:Spacer(debut=".a:debut." fin=".a:fin." cols=".a:cols.")") + call s:SavePosn() + + if a:cols <= 0 + let width = &textwidth + if width <= 0 + let width= &columns + endif + else + let width= a:cols + endif + + let l= a:debut + while l <= a:fin + call setline(l,printf('%-'.width.'s',getline(l))) + let l = l + 1 + endwhile + + call s:RestorePosn() + +" call Dret("s:Spacer") +endf + +" --------------------------------------------------------------------- +" s:CallBox: call the specified function using the current visual selection box {{{2 +fun! s:CallBox(func_name) +" call Dfunc("s:CallBox(func_name<".a:func_name.">)") + + let xdep = b:xmouse_start + let ydep = b:ymouse_start + let col0 = virtcol("'<") + let row0 = line("'<") + let col1 = virtcol("'>") + let row1 = line("'>") +" call Decho("TL corner[".row0.",".col0."] original") +" call Decho("BR corner[".row1.",".col1."] original") +" call Decho("xydep [".ydep.",".xdep."]") + + if col1 == xdep && row1 == ydep + let col1 = col0 + let row1 = row0 + let col0 = xdep + let row0 = ydep + endif +" call Decho("TL corner[".row0.",".col0."]") +" call Decho("BR corner[".row1.",".col1."]") + + " insure that the selected region has blanks to that specified by col1 + call s:AutoCanvas((row0 < row1)? row0 : row1,(row1 > row0)? row1 : row0,(col1 > col0)? col1 : col0) + +" call Decho("exe call s:".a:func_name."(".col0.','.row0.','.col1.','.row1.")") + exe "call s:".a:func_name."(".col0.','.row0.','.col1.','.row1.")" + let b:xmouse_start= 0 + let b:ymouse_start= 0 + +" call Dret("s:CallBox") +endf + +" --------------------------------------------------------------------- +" s:DrawBox: {{{2 +fun! s:DrawBox(x0, y0, x1, y1) +" call Dfunc("s:DrawBox(xy0[".a:x0.",".a:y0." xy1[".a:x1.",".a:y1."])") + " loop each line + let l = a:y0 + while l <= a:y1 + let c = a:x0 + while c <= a:x1 + if l == a:y0 || l == a:y1 + let remp = '-' + if c == a:x0 || c == a:x1 + let remp = '+' + endif + else + let remp = '|' + if c != a:x0 && c != a:x1 + let remp = '.' + endif + endif + + if remp != '.' + call s:SetCharAt(remp, c, l) + endif + let c = c + 1 + endw + let l = l + 1 + endw + +" call Dret("s:DrawBox") +endf + +" --------------------------------------------------------------------- +" s:SetCharAt: set the character at the specified position (must exist) {{{2 +fun! s:SetCharAt(char, x, y) +" call Dfunc("s:SetCharAt(char<".a:char."> xy[".a:x.",".a:y."])") + + let content = getline(a:y) + let long = strlen(content) + let deb = strpart(content, 0, a:x - 1) + let fin = strpart(content, a:x, long) + call setline(a:y, deb.a:char.fin) + +" call Dret("s:SetCharAt") +endf + +" --------------------------------------------------------------------- +" s:DrawLine: Bresenham line-drawing algorithm {{{2 +" taken from : +" http://www.graphics.lcs.mit.edu/~mcmillan/comp136/Lecture6/Lines.html +fun! s:DrawLine(x0, y0, x1, y1, horiz) +" call Dfunc("s:DrawLine(xy0[".a:x0.",".a:y0."] xy1[".a:x1.",".a:y1."] horiz=".a:horiz.")") + + if ( a:x0 < a:x1 && a:y0 > a:y1 ) || ( a:x0 > a:x1 && a:y0 > a:y1 ) + " swap direction + let x0 = a:x1 + let y0 = a:y1 + let x1 = a:x0 + let y1 = a:y0 + else + let x0 = a:x0 + let y0 = a:y0 + let x1 = a:x1 + let y1 = a:y1 + endif + let dy = y1 - y0 + let dx = x1 - x0 + + if dy < 0 + let dy = -dy + let stepy = -1 + else + let stepy = 1 + endif + + if dx < 0 + let dx = -dx + let stepx = -1 + else + let stepx = 1 + endif + + let dy = 2*dy + let dx = 2*dx + + if dx > dy + " move under x + let char = a:horiz + call s:SetCharAt(char, x0, y0) + let fraction = dy - (dx / 2) " same as 2*dy - dx + while x0 != x1 + let char = a:horiz + if fraction >= 0 + if stepx > 0 + let char = '\' + else + let char = '/' + endif + let y0 = y0 + stepy + let fraction = fraction - dx " same as fraction -= 2*dx + endif + let x0 = x0 + stepx + let fraction = fraction + dy " same as fraction = fraction - 2*dy + call s:SetCharAt(char, x0, y0) + endw + else + " move under y + let char = '|' + call s:SetCharAt(char, x0, y0) + let fraction = dx - (dy / 2) + while y0 != y1 + let char = '|' + if fraction >= 0 + if stepy > 0 || stepx < 0 + let char = '\' + else + let char = '/' + endif + let x0 = x0 + stepx + let fraction = fraction - dy + endif + let y0 = y0 + stepy + let fraction = fraction + dx + call s:SetCharAt(char, x0, y0) + endw + endif + +" call Dret("s:DrawLine") +endf + +" --------------------------------------------------------------------- +" s:Arrow: {{{2 +fun! s:Arrow(x0, y0, x1, y1) +" call Dfunc("s:Arrow(xy0[".a:x0.",".a:y0."] xy1[".a:x1.",".a:y1."])") + + call s:DrawLine(a:x0, a:y0, a:x1, a:y1,'-') + let dy = a:y1 - a:y0 + let dx = a:x1 - a:x0 + if s:Abs(dx) > Abs(dy) + " move x + if dx > 0 + call s:SetCharAt('>', a:x1, a:y1) + else + call s:SetCharAt('<', a:x1, a:y1) + endif + else + " move y + if dy > 0 + call s:SetCharAt('v', a:x1, a:y1) + else + call s:SetCharAt('^', a:x1, a:y1) + endif + endif + +" call Dret("s:Arrow") +endf + +" --------------------------------------------------------------------- +" s:Abs: return absolute value {{{2 +fun! s:Abs(val) + if a:val < 0 + return - a:val + else + return a:val + endif +endf + +" --------------------------------------------------------------------- +" s:DrawPlainLine: {{{2 +fun! s:DrawPlainLine(x0,y0,x1,y1) +" call Dfunc("s:DrawPlainLine(xy0[".a:x0.",".a:y0."] xy1[".a:x1.",".a:y1."])") + +" call Decho("exe call s:DrawLine(".a:x0.','.a:y0.','.a:x1.','.a:y1.',"_")') + exe "call s:DrawLine(".a:x0.','.a:y0.','.a:x1.','.a:y1.',"_")' + +" call Dret("s:DrawPlainLine") +endf + +" ===================================================================== +" Mouse Functions: {{{1 +" ===================================================================== + +" --------------------------------------------------------------------- +" s:LeftStart: Read visual drag mapping {{{2 +" The visual start point is saved in b:xmouse_start and b:ymouse_start +fun! s:LeftStart() +" call Dfunc("s:LeftStart()") + let b:xmouse_start = virtcol('.') + let b:ymouse_start = line('.') + vnoremap :call LeftRelease()gv +" call Dret("s:LeftStart : [".b:ymouse_start.",".b:xmouse_start."]") +endf! + +" --------------------------------------------------------------------- +" s:LeftRelease: {{{2 +fun! s:LeftRelease() +" call Dfunc("s:LeftRelease()") + vunmap +" call Dret("s:LeftRelease : [".line('.').','.virtcol('.').']') +endf + +" --------------------------------------------------------------------- +" s:SLeftStart: begin drawing with a brush {{{2 +fun! s:SLeftStart() + if !exists("b:drawit_brush") + let b:drawit_brush= "a" + endif +" call Dfunc("s:SLeftStart() brush=".b:drawit_brush.' ['.line('.').','.virtcol('.').']') + noremap :call SLeftDrag() + noremap :call SLeftRelease() +" call Dret("s:SLeftStart") +endfun + +" --------------------------------------------------------------------- +" s:SLeftDrag: {{{2 +fun! s:SLeftDrag() +" call Dfunc("s:SLeftDrag() brush=".b:drawit_brush.' ['.line('.').','.virtcol('.').']') + call s:SavePosn() + call s:PutBlock(b:drawit_brush,0) + call s:RestorePosn() +" call Dret("s:SLeftDrag") +endfun + +" --------------------------------------------------------------------- +" s:SLeftRelease: {{{2 +fun! s:SLeftRelease() +" call Dfunc("s:SLeftRelease() brush=".b:drawit_brush.' ['.line('.').','.virtcol('.').']') + call s:SLeftDrag() + nunmap + nunmap +" call Dret("s:SLeftRelease") +endfun + +" --------------------------------------------------------------------- +" s:CLeftStart: begin moving a block of text {{{2 +fun! s:CLeftStart() + if !exists("b:drawit_brush") + let b:drawit_brush= "a" + endif +" call Dfunc("s:CLeftStart() brush=".b:drawit_brush) + if !line("'<") || !line("'>") + redraw! + echohl Error + echo "must visual-block select a region first" +" call Dret("s:CLeftStart : must visual-block select a region first") + return + endif + '<,'>call DrawIt#SetBrush(b:drawit_brush) + let s:cleft_width= virtcol("'>") - virtcol("'<") + if s:cleft_width < 0 + let s:cleft_width= -s:cleft_width + endif + let s:cleft_height= line("'>") - line("'<") + if s:cleft_height < 0 + let s:cleft_height= -s:cleft_height + endif +" call Decho("blocksize: ".s:cleft_height."x".s:cleft_width) + noremap :call CLeftDrag() + noremap :call CLeftRelease() +" call Dret("s:CLeftStart") +endfun + +" --------------------------------------------------------------------- +" s:CLeftDrag: {{{2 +fun! s:CLeftDrag() +" call Dfunc("s:CLeftDrag() cleft_width=".s:cleft_width." cleft_height=".s:cleft_height) + exe 'let keepbrush= @'.b:drawit_brush +" call Decho("keepbrush<".keepbrush.">") + + " restore prior contents of block zone + if exists("s:cleft_oldblock") +" call Decho("draw prior contents: [".line(".").",".virtcol(".")."] line($)=".line("$")) +" call Decho("draw prior contents<".s:cleft_oldblock.">") + exe 'let @'.b:drawit_brush.'=s:cleft_oldblock' + call s:PutBlock(b:drawit_brush,1) + else + " first move; put blanks where text had been +" call Decho("first move, put blanks where text was") + norm! gvr + endif + + " move cursor to position + exe "norm! \" + + " save new block zone contents +" call Decho("save contents: [".line(".").",".virtcol(".")."] - [".(line(".")+s:cleft_height).",".(virtcol(".")+s:cleft_width)."]") + let curline= line(".") + call s:AutoCanvas(curline,curline + s:cleft_height,virtcol(".")+s:cleft_width) + if s:cleft_width > 0 && s:cleft_height > 0 + exe "silent! norm! \".s:cleft_width."l".s:cleft_height.'j"'.b:drawit_brush.'y' + elseif s:cleft_width > 0 + exe "silent! norm! \".s:cleft_width.'l"'.b:drawit_brush.'y' + else + exe "silent! norm! \".s:cleft_height.'j"'.b:drawit_brush.'y' + endif + exe "let s:cleft_oldblock= @".b:drawit_brush +" call Decho("cleft_height=".s:cleft_height." cleft_width=".s:cleft_width) +" call Decho("save contents<".s:cleft_oldblock.">") + + " draw the brush +" call Decho("draw brush") +" call Decho("draw brush ".b:drawit_brush.": [".line(".").",".virtcol(".")."] line($)=".line("$")) + exe 'let @'.b:drawit_brush.'=keepbrush' + call s:PutBlock(b:drawit_brush,1) + +" call Dret("s:CLeftDrag") +endfun + +" --------------------------------------------------------------------- +" s:CLeftRelease: {{{2 +fun! s:CLeftRelease() +" call Dfunc("s:CLeftRelease()") + call s:CLeftDrag() + nunmap + nunmap + unlet s:cleft_oldblock s:cleft_height s:cleft_width +" call Dret("s:CLeftRelease") +endfun + +" --------------------------------------------------------------------- +" DrawIt#SetBrush: {{{2 +fun! DrawIt#SetBrush(brush) range +" call Dfunc("DrawIt#SetBrush(brush<".a:brush.">)") + let b:drawit_brush= a:brush +" call Decho("visualmode<".visualmode()."> range[".a:firstline.",".a:lastline."] visrange[".line("'<").",".line("'>")."]") + if visualmode() == "\" && ((a:firstline == line("'>") && a:lastline == line("'<")) || (a:firstline == line("'<") && a:lastline == line("'>"))) + " last visual mode was visual block mode, and + " either [firstline,lastline] == ['<,'>] or ['>,'<] + " Assuming that SetBrush called from a visual-block selection! + " Yank visual block into selected register (brush) +" call Decho("yanking visual block into register ".b:drawit_brush) + exe 'norm! gv"'.b:drawit_brush.'y' + endif +" call Dret("DrawIt#SetBrush : b:drawit_brush=".b:drawit_brush) +endfun + +" ------------------------------------------------------------------------ +" Modelines: {{{1 +" vim: fdm=marker +let &cpo= s:keepcpo +unlet s:keepcpo diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/autoload/textformat.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/autoload/textformat.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,610 @@ +" Text formatter plugin for Vim text editor +" +" Version: 2.1 +" Last Change: 2008-09-13 +" Maintainer: Teemu Likonen +" License: This file is placed in the public domain. +" GetLatestVimScripts: 2324 1 :AutoInstall: TextFormat + +"{{{1 The beginning stuff +if &compatible + finish +endif +let s:save_cpo = &cpo +set cpo&vim + +" Constant variables(s) {{{1 +let s:default_width = 80 + +function! s:Align_Range_Left(...) range "{{{1 + " The optional parameter is the left indent. If it is not given we + " detect the indent used in the buffer. + if a:0 && a:1 >= 0 + " The parameter was given so we just use that as the left + " indent. + let l:leading_ws = s:Retab_Indent(a:1) + for l:line in range(a:firstline,a:lastline) + let l:line_string = getline(l:line) + let l:line_replace = s:Align_String_Left(l:line_string) + if &formatoptions =~ 'w' && l:line_string =~ '\m\s$' + " Preserve trailing whitespace because fo=~w + let l:line_replace .= ' ' + endif + if l:line_replace =~ '\m^\s*$' + call setline(l:line,'') + else + call setline(l:line,l:leading_ws.l:line_replace) + endif + endfor + else + " The parameter was not given so we detect each paragraph's + " indent. + let l:line = a:firstline + while l:line <= a:lastline + let l:line_string = getline(l:line) + if l:line_string =~ '\m^\s*$' + " The line is empty or contains only + " whitespaces so print empty line and + " continue. + call setline(l:line,'') + let l:line += 1 + continue + endif + + " Paragraph (or the whole line range) begins here so + " get the indent of the first line and print the line. + let l:leading_ws = s:Retab_Indent(indent(l:line)) + let l:line_replace = s:Align_String_Left(l:line_string) + if &formatoptions =~ 'w' && l:line_string =~ '\m\s$' + let l:line_replace .= ' ' + endif + call setline(l:line,l:leading_ws.l:line_replace) + let l:line += 1 + + " If fo=~w, does the paragraph end here? If yes, + " continue to next round and find a new first line. + if &formatoptions =~ 'w' && l:line_string =~ '\m\S$' + continue + endif + + " If fo=~2 get the indent of the second line + if &formatoptions =~ '2' + let l:leading_ws = s:Retab_Indent(indent(l:line)) + endif + + " This loop will go through all the lines in the + " paragraph (or till the a:lastline) - starting from + " the second line. + while l:line <= a:lastline && getline(l:line) !~ '\m^\s*$' + let l:line_string = getline(l:line) + let l:line_replace = s:Align_String_Left(l:line_string) + if &formatoptions =~ 'w' + if l:line_string =~ '\m\s$' + call setline(l:line,l:leading_ws.l:line_replace.' ') + let l:line += 1 + continue + else + call setline(l:line,l:leading_ws.l:line_replace) + let l:line += 1 + " fo=~w and paragraph ends + " here so we break the loop. + " The next line is new first + " line. + break + endif + else + call setline(l:line,l:leading_ws.l:line_replace) + let l:line += 1 + endif + endwhile + endwhile + endif +endfunction + +function! s:Align_Range_Right(width) "{{{1 + let l:line_replace = s:Align_String_Right(getline('.'),a:width) + if &formatoptions =~ 'w' && getline('.') =~ '\m\s$' + let l:line_replace .= ' ' + endif + if l:line_replace =~ '\m^\s*$' + " If line would be full of spaces just print empty line. + call setline(line('.'),'') + else + " Retab leading whitespaces + let l:leading_ws = s:Retab_Indent(strlen(substitute(l:line_replace,'\v^( *).*$','\1',''))) + " Get the rest of the line + let l:line_replace = substitute(l:line_replace,'^ *','','') + call setline(line('.'),l:leading_ws.l:line_replace) + endif +endfunction + +function! s:Align_Range_Justify(width, ...) range "{{{1 + " If the optional second argument is given (and is non-zero) each + " paragraph's last line and range's last line is left-aligned. + if a:0 && a:1 + let l:paragraph = 1 + else + let l:paragraph = 0 + endif + let l:line = a:firstline + while l:line <= a:lastline + let l:line_string = getline(l:line) + if l:line_string =~ '\m^\s*$' + " The line is empty or contains only + " whitespaces so print empty line and + " continue. + call setline(l:line,'') + let l:line += 1 + continue + endif + + " Paragraph (or the whole line range) begins here so + " get the indent of the first line and print the line. + let l:indent = indent(l:line) + let l:width = a:width - l:indent + let l:leading_ws = s:Retab_Indent(l:indent) + + if l:paragraph && (l:line == a:lastline || getline(l:line+1) =~ '\m^\s*$' || (&formatoptions =~ 'w' && l:line_string =~ '\m\S$')) + let l:line_replace = s:Align_String_Left(l:line_string) + else + let l:line_replace = s:Align_String_Justify(l:line_string,l:width) + endif + if &formatoptions =~ 'w' && l:line_string =~ '\m\s$' + let l:line_replace .= ' ' + endif + call setline(l:line,l:leading_ws.l:line_replace) + let l:line += 1 + + " If fo=~w, does the paragraph end here? If yes, + " continue to next round and find a new first line. + if &formatoptions =~ 'w' && l:line_string =~ '\m\S$' + continue + endif + + " If fo=~2 get the indent of the second line + if &formatoptions =~ '2' + let l:indent = indent(l:line) + let l:width = a:width - l:indent + let l:leading_ws = s:Retab_Indent(l:indent) + endif + + " This loop will go through all the lines in the + " paragraph (or till the a:lastline) - starting from + " paragraph's second line. + while l:line <= a:lastline && getline(l:line) !~ '\m^\s*$' + let l:line_string = getline(l:line) + if l:paragraph && (l:line == a:lastline || getline(l:line+1) =~ '\m^\s*$' || (&formatoptions =~ 'w' && l:line_string =~ '\m\S$')) + let l:line_replace = s:Align_String_Left(l:line_string) + else + let l:line_replace = s:Align_String_Justify(l:line_string,l:width) + endif + if &formatoptions =~ 'w' + if l:line_string =~ '\m\s$' + call setline(l:line,l:leading_ws.l:line_replace.' ') + let l:line += 1 + continue + else + call setline(l:line,l:leading_ws.l:line_replace) + let l:line += 1 + " fo=~w and paragraph ends + " here so we break the loop. + " The next line is new first + " line. + break + endif + else + call setline(l:line,l:leading_ws.l:line_replace) + let l:line += 1 + endif + endwhile + endwhile +endfunction + +function! s:Align_Range_Center(width) "{{{1 + let l:line_replace = s:Truncate_Spaces(getline('.')) + let l:line_replace = s:Add_Double_Spacing(l:line_replace) + if &formatoptions =~ 'w' && getline('.') =~ '\m\s$' + let l:line_replace .= ' ' + endif + call setline(line('.'),l:line_replace) + execute '.center '.a:width +endfunction + +function! s:Align_String_Left(string) "{{{1 + let l:string_replace = s:Truncate_Spaces(a:string) + let l:string_replace = s:Add_Double_Spacing(l:string_replace) + return l:string_replace +endfunction + +function! s:Align_String_Right(string, width) "{{{1 + let l:string_replace = s:Truncate_Spaces(a:string) + let l:string_replace = s:Add_Double_Spacing(l:string_replace) + let l:string_width = s:String_Width(l:string_replace) + let l:more_spaces = a:width-l:string_width + return repeat(' ',l:more_spaces).l:string_replace +endfunction + +function! s:Align_String_Justify(string, width) "{{{1 + let l:string = s:Truncate_Spaces(a:string) + " If the parameter string is empty we can just return a line full of + " spaces. No need to go further. + if l:string =~ '\m^ *$' + return repeat(' ',a:width) + endif + if s:String_Width(s:Add_Double_Spacing(l:string)) >= a:width + " The original string is longer than width so we can just + " return the string. No need to go further. + return s:Add_Double_Spacing(l:string) + endif + let l:string_width = s:String_Width(l:string) + + " This many extra spaces we need. + let l:more_spaces = a:width-l:string_width + " Convert the string to a list of words. + let l:word_list = split(l:string) + " This is the amount of spaces available in the original string (word + " count minus one). + let l:string_spaces = len(l:word_list)-1 + " If there are no spaces there is only one word. We can just return + " the string with padded spaces. No need to go further. + if l:string_spaces == 0 + return l:string.repeat(' ',l:more_spaces) + endif + " Ok, there are more than one word in the string so we get to do some + " real work... + + " Make a list of which each item represent a space available in the + " string. The value means how many spaces there are. At the moment set + " every list item to one: [1, 1, 1, 1, ...] + let l:space_list = [] + for l:item in range(l:string_spaces) + let l:space_list += [1] + endfor + + " Repeat while there are no more need to add any spaces. + while l:more_spaces > 0 + if l:more_spaces >= l:string_spaces + " More extra spaces are needed than there are spaces + " available in the string so we add one more space + " after every word (add 1 to items of space list). + for l:i in range(l:string_spaces) + let l:space_list[l:i] += 1 + endfor + let l:more_spaces -= l:string_spaces + " And then another round... and a check if more spaces + " are needed. + else " l:more_spaces < l:string_spaces + " This list tells where .?! characters are. + let l:space_sentence_full = [] + " This list tells where ,:; characters are. + let l:space_sentence_semi = [] + " And this is for the rest of spaces. + let l:space_other = [] + " Now, find those things: + for l:i in range(l:string_spaces) + if l:word_list[l:i] =~ '\m\S[.?!]$' + let l:space_sentence_full += [l:i] + elseif l:word_list[l:i] =~ '\m\S[,:;]$' + let l:space_sentence_semi += [l:i] + else + let l:space_other += [l:i] + endif + endfor + + " First distribute spaces after .?! + if l:more_spaces >= len(l:space_sentence_full) + " If we need more extra spaces than there are + " .?! spaces, just add one after every item. + for l:i in l:space_sentence_full + let l:space_list[l:i] += 1 + endfor + let l:more_spaces -= len(l:space_sentence_full) + if l:more_spaces == 0 | break | endif + else + " Distribute the rest of spaces evenly and + " break the loop. All the spaces have been + " added. + for l:i in s:Distributed_Selection(l:space_sentence_full,l:more_spaces) + let l:space_list[l:i] +=1 + endfor + break + endif + + " Then distribute spaces after ,:; + if l:more_spaces >= len(l:space_sentence_semi) + " If we need more extra spaces than there are + " ,:; spaces available, just add one after + " every item. + for l:i in l:space_sentence_semi + let l:space_list[l:i] += 1 + endfor + let l:more_spaces -= len(l:space_sentence_semi) + if l:more_spaces == 0 | break | endif + else + " Distribute the rest of spaces evenly and + " break the loop. All the spaces have been + " added. + for l:i in s:Distributed_Selection(l:space_sentence_semi,l:more_spaces) + let l:space_list[l:i] +=1 + endfor + break + endif + + " Finally distribute spaces to other available + " positions and exit the loop. + for l:i in s:Distributed_Selection(l:space_other,l:more_spaces) + let l:space_list[l:i] +=1 + endfor + break + endif + endwhile + + " Now we now where all the extra spaces will go. We have to construct + " the string again. + let l:string = '' + for l:item in range(l:string_spaces) + let l:string .= l:word_list[l:item].repeat(' ',l:space_list[l:item]) + endfor + " Add the last word to the end and return the string. + return l:string.l:word_list[-1] +endfunction + +function! s:Truncate_Spaces(string) "{{{1 + let l:string = substitute(a:string,'\v\s+',' ','g') + let l:string = substitute(l:string,'\m^\s*','','') + let l:string = substitute(l:string,'\m\s*$','','') + return l:string +endfunction + +function! s:String_Width(string) "{{{1 + " This counts the string width in characters. Combining diacritical + " marks do not count so the base character with all the combined + " diacritics is just one character (which is good for our purposes). + " Double-wide characters will not get double width so unfortunately + " they don't work in our algorithm. + return strlen(substitute(a:string,'\m.','x','g')) +endfunction + +function! s:Add_Double_Spacing(string) "{{{1 + if &joinspaces + return substitute(a:string,'\m\S[.?!] ','& ','g') + else + return a:string + endif +endfunction + +function! s:Distributed_Selection(list, pick) "{{{1 + " 'list' is a list-type variable [ item1, item2, ... ] + " 'pick' is a number how many of the list's items we want to choose + " + " This function returns a list which has 'pick' number of items from + " the original list. Items are chosen in distributed manner. For + " example, if 'pick' is 1 then the algorithm chooses an item near the + " center of the 'list'. If 'pick' is 2 then the first one is about 1/3 + " from the beginning and the another one about 2/3 from the beginning. + + " l:pick_list is a list of 0's and 1's and its length will be the + " same as original list's. Number 1 means that this list item will be + " picked and 0 means that the item will be dropped. Finally + " l:pick_list could look like this: [0, 1, 0, 1, 0] + " (i.e., two items evenly picked from a list of five items) + let l:pick_list = [] + + " First pick items evenly from the beginning of the list. This also + " actually constructs the list. + let l:div1 = len(a:list) / a:pick + let l:mod1 = len(a:list) % a:pick + for l:i in range(len(a:list)-l:mod1) + if !eval(l:i%l:div1) + let l:pick_list += [1] + else + let l:pick_list += [0] + endif + endfor + + if l:mod1 > 0 + " The division wasn't even so we get the remaining items and + " distribute them evenly again to the list. + let l:div2 = len(l:pick_list) / l:mod1 + let l:mod2 = len(l:pick_list) % l:mod1 + for l:i in range(len(l:pick_list)-l:mod2) + if !eval(l:i%l:div2) + call insert(l:pick_list,0,l:i) + endif + endfor + endif + + " There may be very different number of zeros in the beginning and the + " end of the list. We count them. + let l:zeros_begin = 0 + for l:i in l:pick_list + if l:i == 0 + let l:zeros_begin += 1 + else + break + endif + endfor + let l:zeros_end = 0 + for l:i in reverse(copy(l:pick_list)) + if l:i == 0 + let l:zeros_end += 1 + else + break + endif + endfor + + " Then we remove them. + if l:zeros_end + " Remove "0" items from the end. We need to remove them first + " from the end because list items' index number will change + " when items are removed from the beginning. Then it would be + " more difficult to remove trailing zeros. + call remove(l:pick_list,len(l:pick_list)-l:zeros_end,-1) + endif + if l:zeros_begin + " Remove zero items from the beginning. + call remove(l:pick_list,0,l:zeros_begin-1) + endif + let l:zeros_both = l:zeros_begin + l:zeros_end + + " Put even amount of zeros to beginning and end + for l:i in range(l:zeros_both/2) + call insert(l:pick_list,0,0) + endfor + for l:i in range((l:zeros_both/2)+(l:zeros_both%2)) + call add(l:pick_list,0) + endfor + + " Finally construct and return a new list which has only the items we + " have chosen. + let l:new_list = [] + for l:i in range(len(l:pick_list)) + if l:pick_list[l:i] == 1 + let l:new_list += [a:list[l:i]] + endif + endfor + return l:new_list +endfunction + +function! s:Retab_Indent(column) "{{{1 + " column = the left indent column starting from 0 Function returns + " a string of whitespaces, a mixture of tabs and spaces depending on + " the 'expandtab' and 'tabstop' options. + if &expandtab + " Only spaces + return repeat(' ',a:column) + else + " Tabs and spaces + let l:tabs = a:column / &tabstop + let l:spaces = a:column % &tabstop + return repeat("\",l:tabs).repeat(' ',l:spaces) + endif +endfunction + +function! s:Reformat_Range(...) range "{{{1 + if a:0 == 2 + let l:first = a:1 + let l:last = a:2 + else + let l:first = a:firstline + let l:last = a:lastline + endif + let l:autoindent = &autoindent + setlocal autoindent + execute l:first + normal! 0 + execute 'normal! V'.l:last.'G$gw' + let &l:autoindent = l:autoindent + " The formatting may change the last line of the range so we return + " it. + return line("'>") +endfunction + +function! textformat#Visual_Align_Left() range "{{{1 + execute a:firstline.','.a:lastline.'call s:Align_Range_Left()' + call s:Reformat_Range(a:firstline,a:lastline) +endfunction + +function! textformat#Visual_Align_Right() range "{{{1 + let l:width = &textwidth + if l:width == 0 | let l:width = s:default_width | endif + + execute a:firstline.','.a:lastline.'call s:Align_Range_Right('.l:width.')' + normal! '>$ +endfunction + +function! textformat#Visual_Align_Justify() range "{{{1 + let l:width = &textwidth + if l:width == 0 | let l:width = s:default_width | endif + + execute a:firstline.','.a:lastline.'call s:Align_Range_Left()' + + let l:last = s:Reformat_Range(a:firstline,a:lastline) + let l:pos = getpos('.') + execute a:firstline.','.l:last.'call s:Align_Range_Justify('.l:width.',1)' + call setpos('.',l:pos) +endfunction + +function! textformat#Visual_Align_Center() range "{{{1 + let l:width = &textwidth + if l:width == 0 | let l:width = s:default_width | endif + + execute a:firstline.','.a:lastline.'call s:Align_Range_Center('.l:width.')' + normal! '>$ +endfunction + +function! textformat#Quick_Align_Left() "{{{1 + let l:autoindent = &autoindent + setlocal autoindent + let l:pos = getpos('.') + silent normal! vip:call s:Align_Range_Left() + call setpos('.',l:pos) + silent normal! gwip + let &l:autoindent = l:autoindent +endfunction + +function! textformat#Quick_Align_Right() "{{{1 + let l:width = &textwidth + if l:width == 0 | let l:width = s:default_width | endif + let l:pos = getpos('.') + silent normal! vip:call s:Align_Range_Right(l:width) + call setpos('.',l:pos) +endfunction + +function! textformat#Quick_Align_Justify() "{{{1 + let l:width = &textwidth + if l:width == 0 | let l:width = s:default_width | endif + let l:autoindent = &autoindent + setlocal autoindent + let l:pos = getpos('.') + silent normal! vip:call s:Align_Range_Left() + call setpos('.',l:pos) + silent normal! gwip + let l:pos = getpos('.') + silent normal! vip:call s:Align_Range_Justify(l:width,1) + call setpos('.',l:pos) + let &l:autoindent = l:autoindent +endfunction + +function! textformat#Quick_Align_Center() "{{{1 + let l:width = &textwidth + if l:width == 0 | let l:width = s:default_width | endif + let l:pos = getpos('.') + silent normal! vip:call s:Align_Range_Center(l:width) + call setpos('.',l:pos) +endfunction + +function! textformat#Align_Command(align, ...) range "{{{1 + " For left align the optional parameter a:1 is [indent]. For others + " it's [width]. + let l:pos = getpos('.') + if a:align ==? 'left' + if a:0 && a:1 >= 0 + execute a:firstline.','.a:lastline.'call s:Align_Range_Left('.a:1.')' + else + execute a:firstline.','.a:lastline.'call s:Align_Range_Left()' + endif + else + if a:0 && a:1 > 0 + let l:width = a:1 + elseif &textwidth + let l:width = &textwidth + else + let l:width = s:default_width + endif + + if a:align ==? 'right' + execute a:firstline.','.a:lastline.'call s:Align_Range_Right('.l:width.')' + elseif a:align ==? 'justify' + execute a:firstline.','.a:lastline.'call s:Align_Range_Justify('.l:width.')' + elseif a:align ==? 'center' + execute a:firstline.','.a:lastline.'call s:Align_Range_Center('.l:width.')' + endif + endif + call setpos('.',l:pos) +endfunction + +"{{{1 The ending stuff +let &cpo = s:save_cpo + +" vim600: fdm=marker diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/doc/DrawIt.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/doc/DrawIt.txt Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,393 @@ +*drawit.txt* The DrawIt Tool Jul 26, 2007 + +Authors: Charles E. Campbell, Jr. {{{1 + Sylvain Viart + (remove NOSPAM from Campbell's email first) +Copyright: Copyright (C) 2004-2007 Charles E. Campbell, Jr. {{{1 + Permission is hereby granted to use and distribute this code, + with or without modifications, provided that this copyright + notice is copied with it. Like anything else that's free, + DrawIt.vim is provided *as is* and comes with no warranty + of any kind, either expressed or implied. By using this + plugin, you agree that in no event will the copyright + holder be liable for any damages resulting from the use + of this software. + + +============================================================================== +1. Contents *drawit-contents* {{{1 + + 1. Contents......................: |drawit-contents| + 2. DrawIt Manual.................: |drawit| + 3. DrawIt Usage..................: |drawit-usage| + Starting....................: |drawit-start| + Stopping....................: |drawit-stop| + User Map Protection.........: |drawit-protect| + Drawing.....................: |drawit-drawing| + Changing Drawing Characters.: |drawit-setdrawit| + Moving......................: |drawit-moving| + Erasing.....................: |drawit-erase| + Example.....................: |drawit-example| + Visual Block Mode...........: |drawit-visblock| + Brushes.....................: |drawit-brush| + DrawIt Modes................: |drawit-modes| + 4. DrawIt History................: |drawit-history| + + +============================================================================== +2. DrawIt Manual *drawit* {{{1 + *drawit-manual* + /===============+============================================================\ + || Starting & | || + || Stopping | Explanation || + ++--------------+-----------------------------------------------------------++ + || \di | start DrawIt |drawit-start| || + || \ds | stop DrawIt |drawit-stop| || + || :DIstart | start DrawIt |drawit-start| || + || :DIstop | stop DrawIt |drawit-stop| || + || | || + ++==============+===========================================================++ + || Maps | Explanation || + ++--------------+-----------------------------------------------------------++ + || | The DrawIt routines use a replace, move, and || + || | replace/insert strategy. The package also lets one insert|| + || | spaces, draw arrows by using the following characters or || + || | keypad characters: || + || +-----------------------------------------------------------++ + || | move and draw left |drawit-drawing| || + || | move and draw right, inserting lines/space as needed || + || | move and draw up, inserting lines/space as needed || + || | move and draw down, inserting lines/space as needed || + || | move cursor left |drawit-move| || + || | move cursor right, inserting lines/space as needed || + || | move cursor up, inserting lines/space as needed || + || | move cursor down, inserting lines/space as needed || + || | toggle into and out of erase mode || + || > | insert a > and move right (draw -> arrow) || + || < | insert a < and move left (draw <- arrow) || + || ^ | insert a ^ and move up (draw ^ arrow) || + || v | insert a v and move down (draw v arrow) || + || | replace with a \, move down and right, and insert a \ || + || | replace with a /, move down and left, and insert a / || + || | replace with a /, move up and right, and insert a / || + || | replace with a \, move up and left, and insert a \ || + || \> | insert a fat > and move right (draw -> arrow) || + || \< | insert a fat < and move left (draw <- arrow) || + || \^ | insert a fat ^ and move up (draw ^ arrow) || + || \v | insert a fat v and move down (draw v arrow) || + || | drag and draw with current brush |drawit-brush| || + || | drag and move current brush |drawit-brush| || + || | || + ||==============+===========================================================++ + ||Visual Cmds | Explanation || + ||--------------+-----------------------------------------------------------++ + || | The drawing mode routines use visual-block mode to || + || | select endpoints for lines, arrows, and ellipses. Bresen- || + || | ham and Bresenham-like algorithms are used for this. || + || | || + || | These routines need a block of spaces, and so the canvas || + || | routine must first be used to create such a block. The || + || | canvas routine will query the user for the number of || + || | lines to hold |'textwidth'| spaces. || + || +-----------------------------------------------------------++ + || \a | draw arrow from corners of visual-block selected region || + || \b | draw box on visual-block selected region || + || \c | the canvas routine (will query user, see above) || + || \e | draw an ellipse on visual-block selected region || + || \f | flood figure with a character (you will be prompted) || + || \l | draw line from corners of visual-block selected region || + || \s | spacer: appends spaces up to the textwidth (default: 78) || + || | || + ++==============+===========================================================++ + || Function and Explanation || + ++--------------+-----------------------------------------------------------++ + || :call SetDrawIt('vertical','horizontal','crossing','\','/','X','*') || + || set drawing characters for motions for moving || + || and for the ellipse drawing boundary || + || default motion || + || | up/down, || + || - left/right, || + || + -| crossing, || + || \ downright, || + || / downleft, and || + || X \/ crossing || + ++=======================+==================================================++ + || Commands | Explanation || + ++-----------------------+--------------------------------------------------++ + || :SetBrush a-z | sets brush (register) to given register || + || :'<,'>SetBrush a-z | yanks visual block to brush (register) || + \============================================================================/ + + +============================================================================== +3. DrawIt Usage *drawit-usage* {{{1 + +STARTING *drawit-start* {{{2 +\di + +Typically one puts into the .vim/plugin directory +(vimfiles\plugin for Windows) where it becomes always available. It uses a +minimal interface (\di: you can think of it as *D*raw*I*t or *D*rawIt +*I*nitialize) to start it and (\ds: *D*rawIt *S*top) to stop it. Instead of +using "\" you may specify your own preference for a map leader (see +|mapleader|). + +A message, "[DrawIt]", will appear on the message line. + + +STOPPING *drawit-stop* {{{2 +\ds + +When you are done with DrawIt, use \ds to stop DrawIt mode. Stopping DrawIt +will restore your usual options and remove the maps DrawIt set up. + +A message, "[DrawIt off]", will appear on the message line. + + +USER MAP PROTECTION *drawit-protect* {{{2 + +Starting DrawIt causes it to set up a number of maps which facilitate drawing. +DrawIt accomodates users with conflicting maps by saving both maps and user +options and before setting them to what DrawIt needs. When you stop DrawIt +(|drawit-stop|), DrawIt will restore the user's maps and options as they were +before DrawIt was started. + + +OPTIONS *drawit-options* {{{2 + + *g:drawit_insertmode* +g:drawit_insertmode : if this variable exists and is 1 then maps are + made which make cursor-control drawing available + while in insert mode, too. Otherwise, DrawIt's + maps only affect normal mode. + +DRAWING *drawit-drawing* {{{2 + +After DrawIt is started, use the number pad or arrow keys to move the cursor +about. As the cursor moves, DrawIt will then leave appropriate "line" +characters behind as you move horizontally, vertically, or diagonally, and +will transparently enlarge your file to accommodate your drawing as needed. +The trail will consist of -, |, \, / characters (depending on which direction +and SetDrawIt() changes), and + and X characters where line crossings occur. +You may use h-j-k-l to move about your display and generally use editing +commands as you wish even while in DrawIt mode. + + +CHANGING DRAWING CHARACTERS *drawit-setdrawit* {{{2 + +The SetDrawIt() function is available for those who wish to change the +characters that DrawIt uses. > + + ex. :call SetDrawIt('*','*','*','*','*','*','*') + ex. :call SetDrawIt('-','|','-','\','/','/','*') +< +The first example shows how to change all the DrawIt drawing characters to +asterisks, and the second shows how to give crossing priority to - and /. +The default setting is equivalent to: > + + :call SetDrawIt('|','-','+','\','/','X','*') +< +where SetDrawit()'s arguments refer, in order, to the > + + vertical drawing character + horizontal drawing character + horizontal/vertical crossing drawing character + down right drawing character + down left drawing character + diagonal crossing drawing character + ellipse boundary drawing character +< + +MOVING *drawit-move* *drawit-moving* {{{2 + +DrawIt supports shifting the arrow keys to cause motion of the cursor. The +motion of the cursor will not modify what's below the cursor. The cursor +will move and lines and/or spaces will be inserted to support the move as +required. Your terminal may not support shifted arrow keys, however, or Vim +may not catch them as such. For example, on the machine I use, shift-up +() produced [161q, but vim didn't know that sequence was a . +I merely made a nmap: + + nmap [161q + +and vim thereafter recognized the command. + + +ERASING *drawit-erase* {{{2 + + +The key will toggle DrawIt's erase mode/DrawIt mode. When in [DrawIt +erase] mode, a message "[DrawIt erase]" will appear and the number pad will +now cause spaces to be drawn instead of the usual drawing characters. The +drawing behavior will be restored when the key toggles DrawIt back +to regular DrawIt mode. + + +EXAMPLES *drawit-example* {{{2 + +Needless to say, the square spirals which follow were done with DrawIt and +a bit of block editing with Vim: > + + +------------ -----------+ +------------ -----------+ +------------ + |+----------+ +---------+| |+----------+ +---------+| |+----------+ + ||+--------+| |+-------+|| ||+--------+| |+-------+|| ||+--------+| + |||-------+|| ||+------||| |||-------+|| ||+------||| |||-------+|| + ||+-------+|| ||+------+|| ||+-------+|| ||+------+|| ||+-------+|| + |+---------+| |+--------+| |+---------+| |+--------+| |+---------+| + +-----------+ +----------+ +-----------+ +----------+ +-----------+ + +VISUAL BLOCK MODE FOR ARROWS LINES BOXES AND ELLIPSES *drawit-visblock* {{{2 + +\a : draw arrow from corners of visual-block selected region *drawit-a* +\b : draw box on visual-block selected region *drawit-b* +\c : the canvas routine (will query user, see above) *drawit-c* +\e : draw an ellipse on visual-block selected region *drawit-e* +\f : flood figure with a character (you will be prompted) *drawit-f* +\l : draw line from corners of visual-block selected region *drawit-l* +\s : spacer: appends spaces up to the textwidth (default: 78) *drawit-s* + +The DrawIt package has been merged with Sylvain Viart's drawing package (by +permission) which provides DrawIt with visual-block selection of +starting/ending point drawing of arrows (\a), lines (\l), and boxes (\b). +Additionally I wrote an ellipse drawing function using visual block +specification (|drawit-e|). + +One may create a block of spaces for these maps to operate in; the "canvas" +routine (\c) will help create such blocks. First, the s:Canvas() routine will +query the user for the number of lines s/he wishes to have, and will then fill +those lines with spaces out to the |'textwidth'| if user has specified it; +otherwise, the display width will be used. + +The Sylvain Viart functions and the ellipse drawing function depend +upon using visual block mode. As a typical use: > + + Example: * \h + DrawIt asks: how many lines under the cursor? 10 + DrawIt then appends 10 lines filled with blanks + out to textwidth (if defined) or 78 columns. + * ctrl-v (move) \b + DrawIt then draws a box + * ctrl-v (move) \e + DrawIt then draws an ellipse +< +Select the first endpoint with ctrl-v and then move to the other endpoint. +One may then select \a for arrows, \b for boxes, \e for ellipses, or \l for +lines. The internal s:AutoCanvas() will convert tabs to spaces and will +extend with spaces as needed to support the visual block. Note that when +DrawIt is enabled, virtualedit is also enabled (to "all"). +> + Examples: + + __ _ *************** +-------+ + \_ _/ **** **** | | + \_ _/ ** ---------> ** | | + \_ _/ **** **** | | + \__/ <------- *************** +-------+ + + \l \a \e and \a \b +< + *drawit-setbrush* +BRUSHES *drawit-brush* {{{2 +> + :SetBrush a-z +< + Set the current brush to the given letter (actually, its + a named register). Default brush: a > + ex. :SetBrush b + + :'<,'>SetBrush a-z +< + Set the current brush to the given letter, and yank the visual + block to that named register). Default brush: a +> + +< + Select a visual-block region. One may use "ay, for example, + to yank selected text to register a. +> + +< + One may drag and draw with the current brush (default brush: a) + by holding down the shift key and the leftmouse button and moving + the mouse. Blanks in the brush are considered to be transparent. +> + +< + One may drag and move a selection with . First, + select the region using the . Release the mouse button, + then press ctrl and the button; while continuing to press + the button, move the mouse. The selected block of text will then + move along with the cursor. +> + \ra ... \rz +< + Replace text with the given register's contents (ie. the brush). +> + \pa ... \pz +< + Like \ra ... \rz, except that blanks are considered to be transparent. + + Example: Draw the following > + \ \ + o o + * + --- +< Then use ctrl-v, move, "ay to grab a copy into register a. + By default, the current brush uses register a (change brush + with :SetBrush [reg]). Hold the and + keys down and move the mouse; as you move, a copy of the + brush will be left behind. + + +DRAWIT MODES *drawit-modes* {{{2 + + -[DrawIt] regular DrawIt mode (|drawit-start|) + -[DrawIt off] DrawIt is off (|drawit-stop| ) + -[DrawIt erase] DrawIt will erase using the number pad (|drawit-erase|) + + g:DrChipTopLvlMenu: by default its "DrChip"; you may set this to whatever + you like in your <.vimrc>. This variable controls where + DrawIt's menu items are placed. + + +============================================================================== +4. History *drawit-history* {{{1 + + 8 Feb 12, 2007 * fixed a bug which prevented multi-character user + maps from being restored properly + May 03, 2007 * Extended SetDrawIt() to handle b:di_ellipse, the + ellipse boundary drawing character + * Changed "Holer" to "Canvas", and wrote AutoCanvas(), + which allow one to use the visual-block drawing + maps without creating a canvas first. + * DrawIt now uses the ctrl-leftmouse to move a visual + block selected region. + * Floods can now be done inside an ellipse + * DrawIt's maps are now all users of + 7 Feb 16, 2005 * now checks that "m" is in &go before attempting to + use menus + Aug 17, 2005 * report option workaround + Nov 01, 2005 * converted DrawIt to use autoload feature of vim 7.0 + Dec 28, 2005 * now uses cecutil to save/restore user maps + Jan 18, 2006 * cecutil now updated to use keepjumps + Jan 23, 2006 * :DIstart and :DIstop commands provided; thus users + using "set noremap" can still use DrawIt. + Jan 26, 2006 * DrawIt menu entry now keeps its place + Apr 10, 2006 * Brushes were implemented + 6 Feb 24, 2003 * The latest DrawIt now provides a fill function. + \f will ask for a character to fill the figure + surrounding the current cursor location. Plus + I suggest reading :he drawit-tip for those whose + home/pageup/pagedown/end keys aren't all working + properly with DrawIt. + 08/18/03 : \p[a-z] and \r[a-z] implemented + 08/04/03 : b:..keep variables renamed to b:di_..keep variables + StopDrawIt() now insures that erase mode is off + 03/11/03 : included g:drawit_insertmode handling + 02/21/03 : included flood function + 12/11/02 : deletes trailing whitespace only if holer used + 8/27/02 : fat arrowheads included + : shift-arrow keys move but don't modify + + --------------------------------------------------------------------- +vim:tw=78:ts=8:ft=help:fdm=marker diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/doc/bufexplorer.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/doc/bufexplorer.txt Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,502 @@ +*bufexplorer.txt* Buffer Explorer Last Change: 16 Feb 2010 + +Buffer Explorer *buffer-explorer* *bufexplorer* + Version 7.2.7 + +Plugin for easily exploring (or browsing) Vim |:buffers|. + +|bufexplorer-installation| Installation +|bufexplorer-usage| Usage +|bufexplorer-windowlayout| Window Layout +|bufexplorer-customization| Customization +|bufexplorer-changelog| Change Log +|bufexplorer-todo| Todo +|bufexplorer-credits| Credits + +For Vim version 7.0 and above. +This plugin is only available if 'compatible' is not set. + +{Vi does not have any of this} + +============================================================================== +INSTALLATION *bufexplorer-installation* + +To install: + - Download the bufexplorer.zip. + - Extract the zip archive into your runtime directory. + The archive contains plugin/bufexplorer.vim, and doc/bufexplorer.txt. + - Start Vim or goto an existing instance of Vim. + - Execute the following command: +> + :helptag /doc +< + This will generate all the help tags for any file located in the doc + directory. + +============================================================================== +USAGE *bufexplorer-usage* + +To start exploring in the current window, use: > + \be or :BufExplorer +To start exploring in a newly split horizontal window, use: > + \bs or :BufExplorerHorizontalSplit +To start exploring in a newly split vertical window, use: > + \bv or :BufExplorerVerticalSplit + +If you would like to use something other than '\', you may simply change the +leader (see |mapleader|). + +Note: If the current buffer is modified when bufexplorer started, the current + window is always split and the new bufexplorer is displayed in that new + window. + +Commands to use once exploring: + + Toggle help information. + Opens the buffer that is under the cursor into the current + window. + Opens the buffer that is under the cursor into the current + window. + Opens the buffer that is under the cursor in another tab. + d |:delete|the buffer under the cursor from the list. The + buffer's 'buflisted' is cleared. This allows for the buffer to + be displayed again using the 'show unlisted' command. + R Toggles relative path/absolute path. + T Toggles to show only buffers for this tab or not. + D |:wipeout|the buffer under the cursor from the list. When a + buffers is wiped, it will not be shown when unlisted buffer are + displayed. + f Toggles whether you are taken to the active window when + selecting a buffer or not. + o Opens the buffer that is under the cursor into the current + window. + p Toggles the showing of a split filename/pathname. + q Quit exploring. + r Reverses the order the buffers are listed in. + s Selects the order the buffers are listed in. Either by buffer + number, file name, file extension, most recently used (MRU), or + full path. + t Opens the buffer that is under the cursor in another tab. + u Toggles the showing of "unlisted" buffers. + +Once invoked, Buffer Explorer displays a sorted list (MRU is the default +sort method) of all the buffers that are currently opened. You are then +able to move the cursor to the line containing the buffer's name you are +wanting to act upon. Once you have selected the buffer you would like, +you can then either open it, close it(delete), resort the list, reverse +the sort, quit exploring and so on... + +=============================================================================== +WINDOW LAYOUT *bufexplorer-windowlayout* + +------------------------------------------------------------------------------- +" Press for Help +" Sorted by mru | Locate buffer | Absolute Split path +"= + 01 %a bufexplorer.txt C:\Vim\vimfiles\doc line 87 + 02 # bufexplorer.vim c:\Vim\vimfiles\plugin line 1 +------------------------------------------------------------------------------- + | | | | | + | | | | +-- Current Line #. + | | | +-- Relative/Full Path + | | +-- Buffer Name. + | +-- Buffer Attributes. See|:buffers|for more information. + +-- Buffer Number. See|:buffers|for more information. + +=============================================================================== +CUSTOMIZATION *bufexplorer-customization* + + *g:bufExplorerDefaultHelp* +To control whether the default help is displayed or not, use: > + let g:bufExplorerDefaultHelp=0 " Do not show default help. + let g:bufExplorerDefaultHelp=1 " Show default help. +The default is to show the default help. + + *g:bufExplorerDetailedHelp* +To control whether detailed help is display by, use: > + let g:bufExplorerDetailedHelp=0 " Do not show detailed help. + let g:bufExplorerDetailedHelp=1 " Show detailed help. +The default is NOT to show detailed help. + + *g:bufExplorerFindActive* +To control whether you are taken to the active window when selecting a buffer, +use: > + let g:bufExplorerFindActive=0 " Do not go to active window. + let g:bufExplorerFindActive=1 " Go to active window. +The default is to be taken to the active window. + + *g:bufExplorerReverseSort* +To control whether to sort the buffer in reverse order or not, use: > + let g:bufExplorerReverseSort=0 " Do not sort in reverse order. + let g:bufExplorerReverseSort=1 " Sort in reverse order. +The default is NOT to sort in reverse order. + + *g:bufExplorerShowDirectories* +Directories usually show up in the list from using a command like ":e .". +To control whether to show directories in the buffer list or not, use: > + let g:bufExplorerShowDirectories=1 " Show directories. + let g:bufExplorerShowDirectories=0 " Don't show directories. +The default is to show directories. + + *g:bufExplorerShowRelativePath* +To control whether to show absolute paths or relative to the current +directory, use: > + let g:bufExplorerShowRelativePath=0 " Show absolute paths. + let g:bufExplorerShowRelativePath=1 " Show relative paths. +The default is to show absolute paths. + + *g:bufExplorerShowUnlisted* +To control whether to show unlisted buffer or not, use: > + let g:bufExplorerShowUnlisted=0 " Do not show unlisted buffers. + let g:bufExplorerShowUnlisted=1 " Show unlisted buffers. +The default is to NOT show unlisted buffers. + + *g:bufExplorerSortBy* +To control what field the buffers are sorted by, use: > + let g:bufExplorerSortBy='extension' " Sort by file extension. + let g:bufExplorerSortBy='fullpath' " Sort by full file path name. + let g:bufExplorerSortBy='mru' " Sort by most recently used. + let g:bufExplorerSortBy='name' " Sort by the buffer's name. + let g:bufExplorerSortBy='number' " Sort by the buffer's number. +The default is to sort by mru. + + *g:bufExplorerSplitBelow* +To control where the new split window will be placed above or below the +current window, use: > + let g:bufExplorerSplitBelow=1 " Split new window below current. + let g:bufExplorerSplitBelow=0 " Split new window above current. +The default is to use what ever is set by the global &splitbelow +variable. + + *g:bufExplorerSplitOutPathName* +To control whether to split out the path and file name or not, use: > + let g:bufExplorerSplitOutPathName=1 " Split the path and file name. + let g:bufExplorerSplitOutPathName=0 " Don't split the path and file + " name. +The default is to split the path and file name. + + *g:bufExplorerSplitRight* +To control where the new vsplit window will be placed to the left or right of +current window, use: > + let g:bufExplorerSplitRight=0 " Split left. + let g:bufExplorerSplitRight=1 " Split right. +The default is to use the global &splitright. + + *g:bufExplorerShowTabBuffer* +To control weither or not to show buffers on for the specific tab or not, use: > + let g:bufExplorerShowTabBuffer=0 " No. + let g:bufExplorerShowTabBuffer=1 " Yes. +The default is not to show. + +=============================================================================== +CHANGE LOG *bufexplorer-changelog* + +7.2.7 - Fix: + * My 1st attempt to fix the "cache" issue where buffers information + has changed but the cache/display does not reflect those changes. + More work still needs to be done. +7.2.6 - Fix: + * Thanks to Michael Henry for pointing out that I totally forgot to + update the inline help to reflect the previous change to the 'd' + and 'D' keys. Opps! +7.2.5 - Fix: + * Philip Morant suggested switching the command (bwipe) associated + with the 'd' key with the command (bdelete) associated with the 'D' + key. This made sense since the 'd' key is more likely to be used + compared to the 'D' key. +7.2.4 - Fix: + * I did not implement the patch provided by Godefroid Chapelle + correctly. I missed one line which happened to be the most + important one :) +7.2.3 - Enhancements: + * Thanks to David Fishburn for helping me out with a much needed + code overhaul as well as some awesome performance enhancements. + He also reworked the handling of tabs. + * Thanks to Vladimir Dobriakov for making the suggestions on + enhancing the documentation to include a better explaination of + what is contained in the main bufexplorer window. + * Thanks to Yuriy Ershov for added code that when the bufexplorer + window is opened, the cursor is now positioned at the line with the + active buffer (useful in non-MRU sort modes). + * Yuriy also added the abiltiy to cycle through the sort fields in + reverse order. + Fixes: + * Thanks to Michael Henry for supplying a patch that allows + bufexplorer to be opened even when there is one buffer or less. + * Thanks to Godefroid Chapelle for supplying a patch that fixed + MRU sort order after loading a session. +7.2.2 - Fixes: + * Thanks to David L. Dight for spotting and fixing an issue when + using ctrl^. bufexplorer would incorrectly handle the previous + buffer so that when ctrl^ was pressed the incorrect file was opened. +7.2.1 - Fixes: + * Thanks to Dimitar for spotting and fixing a feature that was + inadvertently left out of the previous version. The feature was + when bufexplorer was used together with WinManager, you could use + the tab key to open a buffer in a split window. +7.2.0 - Enhancements: + * For all those missing the \bs and \bv commands, these have now + returned. Thanks to Phil O'Connell for asking for the return of + these missing features and helping test out this version. + Fixes: + * Fixed problem with the bufExplorerFindActive code not working + correctly. + * Fixed an incompatibility between bufexplorer and netrw that caused + buffers to be incorrectly removed from the MRU list. +7.1.7 - Fixes: + * TaCahiroy fixed several issues related to opening a buffer in a + tab. +7.1.6 - Fixes: + * Removed ff=unix from modeline in bufexplorer.txt. Found by Bill + McCarthy. +7.1.5 - Fixes: + * Could not open unnamed buffers. Fixed by TaCahiroy. +7.1.4 - Fixes: + * Sometimes when a file's path has 'white space' in it, extra buffers + would be created containing each piece of the path. i.e: + opening c:\document and settings\test.txt would create a buffer + named "and" and a buffer named "Documents". This was reported and + fixed by TaCa Yoss. +7.1.3 - Fixes: + * Added code to allow only one instance of the plugin to run at a + time. Thanks Dennis Hostetler. +7.1.2 - Fixes: + * Fixed a jumplist issue spotted by JiangJun. I overlooked the + 'jumplist' and with a couple calls to 'keepjumps', everything is + fine again. + * Went back to just having a plugin file, no autoload file. By having + the autoload, WinManager was no longer working and without really + digging into the cause, it was easier to go back to using just a + plugin file. +7.1.1 - Fixes: + * A problem spotted by Thomas Arendsen Hein. + When running Vim (7.1.94), error E493 was being thrown. + Enhancements: + * Added 'D' for 'delete' buffer as the 'd' command was a 'wipe' + buffer. +7.1.0 - Another 'major' update, some by Dave Larson, some by me. + * Making use of 'autoload' now to make the plugin load quicker. + * Removed '\bs' and '\bv'. These are now controlled by the user. The + user can issue a ':sp' or ':vs' to create a horizontal or vertical + split window and then issue a '\be' + * Added handling of tabs. +7.0.17 - Fixed issue with 'drop' command. + Various enhancements and improvements. +7.0.16 - Fixed issue reported by Liu Jiaping on non Windows systems, which was + ... + Open file1, open file2, modify file1, open bufexplorer, you get the + following error: + + --------8<-------- + Error detected while processing function + 14_StartBufExplorer..14_SplitOpen: + line 4: + E37: No write since last change (add ! to override) + + But the worse thing is, when I want to save the current buffer and + type ':w', I get another error message: + E382: Cannot write, 'buftype' option is set + --------8<-------- + +7.0.15 - Thanks to Mark Smithfield for suggesting bufexplorer needed to handle + the ':args' command. +7.0.14 - Thanks to Randall Hansen for removing the requirement of terminal + versions to be recompiled with 'gui' support so the 'drop' command + would work. The 'drop' command is really not needed in terminal + versions. +7.0.13 - Fixed integration with WinManager. + Thanks to Dave Eggum for another update. + - Fix: The detailed help didn't display the mapping for toggling + the split type, even though the split type is displayed. + - Fixed incorrect description in the detailed help for toggling + relative or full paths. + - Deprecated s:ExtractBufferNbr(). Vim's str2nr() does the same + thing. + - Created a s:Set() function that sets a variable only if it hasn't + already been defined. It's useful for initializing all those + default settings. + - Removed checks for repetitive command definitions. They were + unnecessary. + - Made the help highlighting a little more fancy. + - Minor reverse compatibility issue: Changed ambiguous setting + names to be more descriptive of what they do (also makes the code + easier to follow): + Changed bufExplorerSortDirection to bufExplorerReverseSort + Changed bufExplorerSplitType to bufExplorerSplitVertical + Changed bufExplorerOpenMode to bufExplorerUseCurrentWindow + - When the BufExplorer window closes, all the file-local marks are + now deleted. This may have the benefit of cleaning up some of the + jumplist. + - Changed the name of the parameter for StartBufExplorer from + "split" to "open". The parameter is a string which specifies how + the buffer will be open, not if it is split or not. + - Deprecated DoAnyMoreBuffersExist() - it is a one line function + only used in one spot. + - Created four functions (SplitOpen(), RebuildBufferList(), + UpdateHelpStatus() and ReSortListing()) all with one purpose - to + reduce repeated code. + - Changed the name of AddHeader() to CreateHelp() to be more + descriptive of what it does. It now returns an array instead of + updating the window directly. This has the benefit of making the + code more efficient since the text the function returns is used a + little differently in the two places the function is called. + - Other minor simplifications. +7.0.12 - MAJOR Update. + This version will ONLY run with Vim version 7.0 or greater. + Dave Eggum has made some 'significant' updates to this latest + version: + - Added BufExplorerGetAltBuf() global function to be used in the + user’s rulerformat. + - Added g:bufExplorerSplitRight option. + - Added g:bufExplorerShowRelativePath option with mapping. + - Added current line highlighting. + - The split type can now be changed whether bufexplorer is opened + in split mode or not. + - Various major and minor bug fixes and speed improvements. + - Sort by extension. + Other improvements/changes: + - Changed the help key from '?' to to be more 'standard'. + - Fixed splitting of vertical bufexplorer window. + Hopefully I have not forgot something :) +7.0.11 - Fixed a couple of highlighting bugs, reported by David Eggum. He also + changed passive voice to active on a couple of warning messages. +7.0.10 - Fixed bug report by Xiangjiang Ma. If the 'ssl' option is set, + the slash character used when displaying the path was incorrect. +7.0.9 - Martin Grenfell found and eliminated an annoying bug in the + bufexplorer/winmanager integration. The bug was were an + annoying message would be displayed when a window was split or + a new file was opened in a new window. Thanks Martin! +7.0.8 - Thanks to Mike Li for catching a bug in the WinManager integration. + The bug was related to the incorrect displaying of the buffer + explorer's window title. +7.0.7 - Thanks to Jeremy Cowgar for adding a new enhancement. This + enhancement allows the user to press 'S', that is capital S, which + will open the buffer under the cursor in a newly created split + window. +7.0.6 - Thanks to Larry Zhang for finding a bug in the "split" buffer code. + If you force set g:bufExplorerSplitType='v' in your vimrc, and if you + tried to do a \bs to split the bufexplorer window, it would always + split horizontal, not vertical. He also found that I had a typeo in + that the variable g:bufExplorerSplitVertSize was all lower case in + the documentation which was incorrect. +7.0.5 - Thanks to Mun Johl for pointing out a bug that if a buffer was + modified, the '+' was not showing up correctly. +7.0.4 - Fixed a problem discovered first by Xiangjiang Ma. Well since I've + been using vim 7.0 and not 6.3, I started using a function (getftype) + that is not in 6.3. So for backward compatibility, I conditionaly use + this function now. Thus, the g:bufExplorerShowDirectories feature is + only available when using vim 7.0 and above. +7.0.3 - Thanks to Erwin Waterlander for finding a problem when the last + buffer was deleted. This issue got me to rewrite the buffer display + logic (which I've wanted to do for sometime now). + Also great thanks to Dave Eggum for coming up with idea for + g:bufExplorerShowDirectories. Read the above information about this + feature. +7.0.2 - Thanks to Thomas Arendsen Hein for finding a problem when a user + has the default help turned off and then brought up the explorer. An + E493 would be displayed. +7.0.1 - Thanks to Erwin Waterlander for finding a couple problems. + The first problem allowed a modified buffer to be deleted. Opps! The + second problem occurred when several files were opened, BufExplorer + was started, the current buffer was deleted using the 'd' option, and + then BufExplorer was exited. The deleted buffer was still visible + while it is not in the buffers list. Opps again! +7.0.0 - Thanks to Shankar R. for suggesting to add the ability to set + the fixed width (g:bufExplorerSplitVertSize) of a new window + when opening bufexplorer vertically and fixed height + (g:bufExplorerSplitHorzSize) of a new window when opening + bufexplorer horizontally. By default, the windows are normally + split to use half the existing width or height. +6.3.0 - Added keepjumps so that the jumps list would not get cluttered with + bufexplorer related stuff. +6.2.3 - Thanks to Jay Logan for finding a bug in the vertical split position + of the code. When selecting that the window was to be split + vertically by doing a '\bv', from then on, all splits, i.e. '\bs', + were split vertically, even though g:bufExplorerSplitType was not set + to 'v'. +6.2.2 - Thanks to Patrik Modesto for adding a small improvement. For some + reason his bufexplorer window was always showing up folded. He added + 'setlocal nofoldenable' and it was fixed. +6.2.1 - Thanks goes out to Takashi Matsuo for added the 'fullPath' sorting + logic and option. +6.2.0 - Thanks goes out to Simon Johann-Ganter for spotting and fixing a + problem in that the last search pattern is overridden by the search + pattern for blank lines. +6.1.6 - Thanks to Artem Chuprina for finding a pesky bug that has been around + for sometime now. The key mapping was causing the buffer + explored to close prematurely when vim was run in an xterm. The + key mapping is now removed. +6.1.5 - Thanks to Khorev Sergey. Added option to show default help or not. +6.1.4 - Thanks goes out to Valery Kondakoff for suggesting the addition of + setlocal nonumber and foldcolumn=0. This allows for line numbering + and folding to be turned off temporarily while in the explorer. +6.1.3 - Added folding. Did some code cleanup. Added the ability to force the + newly split window to be temporarily vertical, which was suggested by + Thomas Glanzmann. +6.1.2 - Now pressing the key will quit, just like 'q'. + Added folds to hide winmanager configuration. + If anyone had the 'C' option in their cpoptions they would receive + a E10 error on startup of BufExplorer. cpo is now saved, updated and + restored. Thanks to Charles E Campbell, Jr. + Attempted to make sure there can only be one BufExplorer window open + at a time. +6.1.1 - Thanks to Brian D. Goodwin for adding toupper to FileNameCmp. This + way buffers sorted by name will be in the correct order regardless of + case. +6.0.16 - Thanks to Andre Pang for the original patch/idea to get bufexplorer + to work in insertmode/modeless mode (evim). Added Initialize + and Cleanup autocommands to handle commands that need to be + performed when starting or leaving bufexplorer. +6.0.15 - Srinath Avadhanulax added a patch for winmanager.vim. +6.0.14 - Fix a few more bug that I thought I already had fixed. Thanks + to Eric Bloodworth for adding 'Open Mode/Edit in Place'. Added + vertical splitting. +6.0.13 - Thanks to Charles E Campbell, Jr. for pointing out some embarrassing + typos that I had in the documentation. I guess I need to run + the spell checker more :o) +6.0.12 - Thanks to Madoka Machitani, for the tip on adding the augroup command + around the MRUList autocommands. +6.0.11 - Fixed bug report by Xiangjiang Ma. '"=' was being added to the + search history which messed up hlsearch. +6.0.10 - Added the necessary hooks so that the Srinath Avadhanula's + winmanager.vim script could more easily integrate with this script. + Tried to improve performance. +6.0.9 - Added MRU (Most Recently Used) sort ordering. +6.0.8 - Was not resetting the showcmd command correctly. + Added nifty help file. +6.0.7 - Thanks to Brett Carlane for some great enhancements. Some are added, + some are not, yet. Added highlighting of current and alternate + filenames. Added splitting of path/filename toggle. Reworked + ShowBuffers(). + Changed my email address. +6.0.6 - Copyright notice added. Needed this so that it could be distributed + with Debian Linux. Fixed problem with the SortListing() function + failing when there was only one buffer to display. +6.0.5 - Fixed problems reported by David Pascoe, in that you where unable to + hit 'd' on a buffer that belonged to a files that no longer existed + and that the 'yank' buffer was being overridden by the help text when + the bufexplorer was opened. +6.0.4 - Thanks to Charles Campbell, Jr. for making this plugin more plugin + *compliant*, adding default keymappings of be and bs + as well as fixing the 'w:sortDirLabel not being defined' bug. +6.0.3 - Added sorting capabilities. Sort taken from explorer.vim. +6.0.2 - Can't remember. (2001-07-25) +6.0.1 - Initial release. + +=============================================================================== +TODO *bufexplorer-todo* + +- Nothing as of now, buf if you have any suggestions, drop me an email. + +=============================================================================== +CREDITS *bufexplorer-credits* + +Author: Jeff Lanzarotta + +Credit must go out to Bram Moolenaar and all the Vim developers for +making the world's best editor (IMHO). I also want to thank everyone who +helped and gave me suggestions. I wouldn't want to leave anyone out so I +won't list names. + +=============================================================================== +vim:tw=78:noet:wrap:ts=8:ft=help:norl: diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/doc/project.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/doc/project.txt Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,710 @@ +*project.txt* Plugin for managing multiple projects with multiple sources + For Vim version 6.x and Vim version 7.x. + Last Change: Fri 13 Oct 2006 10:20:13 AM EDT + + + By Aric Blumer + aricvim email-at-sign charter.net + + *project* *project-plugin* + Contents: + + Commands...................|project-invoking| + Inheritance.............|project-inheritance| + Mappings...................|project-mappings| + Adding Mappings.....|project-adding-mappings| + Settings...................|project-settings| + Example File................|project-example| + Tips...........................|project-tips| + + +You can use this plugin's basic functionality to set up a list of +frequently-accessed files for easy navigation. The list of files will be +displayed in a window on the left side of the Vim window, and you can press + or double-click on filenames in the list to open the files. I find +this easier to use than having to navigate a directory hierarchy with the +|file-explorer|. + +You can also instruct the Plugin to change to a directory and to run Vim +scripts when you select a file. These scripts can, for example, modify the +environment to include compilers in $PATH. This makes it very easy to use +quickfix with multiple projects that use different environments. + +Other features include: + o Loading/Unloading all the files in a Project (\l, \L, \w, and \W) + o Grepping all the files in a Project (\g and \G) + o Running a user-specified script on a file (can be used to launch an + external program on the file) (\1 through \9) + o Running a user-specified script on all the files in a Project + (\f1-\f9 and \F1-\F9) + o High degree of user-configurability + o Also works with |netrw| using the XXXX://... notation where XXXX is + ftp, rcp, scp, or http. + +All of this is specified within a simple text file and a few global variables +in your vimrc file. + +You must set 'nocompatible' in your |vimrc| file to use this plugin. You can +stop the plugin from being loaded by setting the "loaded_project" variable: > + :let loaded_project = 1 + + +============================================================================== +COMMANDS *project-invoking* + +You can use the plugin by placing it in your plugin directory (e.g., +~/.vim/plugin). See |add-global-plugin|. When you start vim the next time, you +then enter the command > + :Project +or > + :Project {file} + +If you do not specify the filename, $HOME/.vimprojects is used. + +To have Vim come up with the Project Window enabled automatically (say, from a +GUI launcher), run Vim like this: [g]vim +Project + +Note that you can invoke :Project on only one file at a time. If you wish to +change the Project File, do a :bwipe in the Project Buffer, then re-invoke the +Plugin as described above. + +Several Projects can be kept and displayed in the same file, each in a fold +delimited by { and } (see |fold.txt|). There can be any number of nested +folds to provide you with a Project hierarchy. Any line without a { or a } in +the file is considered to be a filename. Blank lines are ignored, and any +text after a # is ignored. + +Because the plugin uses standard Vim folds, you can use any of the +|fold-commands|. You can double-click on the first line of a fold to open and +close it. You can select a file to open by putting the cursor on its name and +pressing or by double-clicking on it. The plugin will create a new +window to the right or use the |CTRL-W_p| equivalent if it exists. + + *project-syntax* +Each Project Entry has this form: + +project_entry ::= + ={projpath} [{options}] { + [ filename ] + [ project_entry ] + } + +{options} is one or more of the following (on the same line): + CD={path} + in={filename} + out={filename} + filter="{pat}" + flags={flag} + +Note that a project_entry can reside within a project_entry. This allows you +to set up a hierarchy within your Project. + +The will be displayed in the foldtext and cannot contain "=". +There can be no space character directly on either side of the =. + +The {projpath} is the path in which the files listed in the Project's fold +will be found, and it may contain environment variables. If the path is a +relative path, then the plugin constructs the whole path from the Project's +parent, grandparent, etc., all the way up the hierarchy. An outermost +project_entry must have an absolute path. See the |project-inheritance| +example below. {projpath} may contain spaces, but they must be escaped like +normal Vim escapes. Here are two examples of the same directory: +> + Example=/my/directory/with\ spaces { + } + Example="/my/directory/with spaces" { + } + +I recommend this for Windows®: > + + Example="c:\My Documents" { + } + +But Vim is smart enough to do this, too: > + + Example=c:\My\ Documents { + } + +CD= provides the directory that Vim will change to when you select a file in +that fold (using |:cd|). This allows you, for example, to enter |:make| to use +the local Makefile. A CD=. means that Vim will make {projpath} or its +inherited equivalent the current working directory. When CD is omitted, the +directory is not changed. There can be no space on either side of the =. The +value of CD can also be a relative path from a parent's CD. See the +|project-inheritance| example below. This directive is ignored for |netrw| +projects. Spaces are allowed in the path as for {projpath}. + +in= and out= provide the means to run arbitrary Vim scripts whenever you enter +or leave a file's buffer (see the |BufEnter| and |BufLeave| autocommand +events). The idea is to have a Vim script that sets up or tears down the +environment for the Project like this: + +in.vim: > + let $PROJECT_HOME='~/my_project' + " Put the compiler in $PATH + if $PATH !~ '/path/to/my/compiler' + let $PATH=$PATH.':/path/to/my/compiler' + endif + +out.vim: > + " Remove compiler from $PATH + if $PATH =~ '/path/to/my/compiler' + let $PATH=substitute($PATH, ':/path/to/my/compiler', '', 'g') + endif + +Then you can use :make with the proper environment depending on what file you +are currently editing. If the path to the script is relative, then it is +relative from {projpath}. These directives are inherited by Subprojects +unless the Subproject specifies its own. For use with |netrw| projects, the +paths specified for in= and out= must be absolute and local. + +filter= specifies a |glob()| file pattern. It is used to regenerate the list +of files in a Project fold when using the \r (r) map in the +Project Window. The filter value must be in quotes because it can contain +multiple file patterns. If filter is omitted, then the * pattern is used. +There can be no space on either side of the =. A Subproject will inherit the +filter of its parent unless it specifies its own filter. + +flags= provides the means to enable/disable features for a particular fold. +The general mnemonic scheme is for lower case to turn something off and upper +case to turn something on. {flag} can contain any of the following +characters: + + flag Description ~ + + l Turn off recursion for this fold for \L. Subfolds are also + blocked from the recursion. + + r Turn off refresh. When present, do not refresh this fold when + \r or \R is used. This does not affect subfold recursion. + + S Turn on sorting for refresh and create. + + s Turn off sorting for refresh and create. + + T Turn on top gravity. Forces folds to the top of the current + fold when refreshing. It has the same affect as the 'T' flag + in g:proj_flags, but controls the feature on a per-fold basis. + + t Turn off top gravity. Forces folds to the bottom of the + current fold when refreshing. + + w Turn off recursion for this fold for \W. Subfolds are also + blocked from the recursion. + + +Flags are not inherited by Subprojects. + +Any text outside a fold is ignored. + + +============================================================================== +INHERITANCE *project-inheritance* + +It's best to show inheritance by comparing these two Project Files: +> + Parent=~/my_project CD=. filter="Make* *.mk" flags=r { + Child1=c_code { + } + Child2=include CD=. filter="*.h" { + } + } + +Child1's path is "~/my_project/c_code" because ~/my_project is inherited. It +also inherits the CD from Parent. Since Parent has CD=., the Parent's cwd is +"~/my_project". Child1 therefore inherits a CD of "~/my_project". Finally, +Child1 inherits the filter from Parent. The flags are not inherited. + +Child2 only inherits the "~/my_project" from Parent. + +Thus, the example above is exactly equivalent to this: +> + Parent=~/my_project CD=. filter="Make* *.mk" flags=r { + Child1=~/my_project/c_code CD=~/my_project filter="Make* *.mk" { + } + Child2=~/my_project/include CD=~/my_project/include filter="*.h" { + } + } + +(For a real Project, Child1 would not want to inherit its parent's filter, but +this example shows the concept.) You can always enter \i to display what the +cursor's project inherits. + + +============================================================================== +MAPPINGS *project-mappings* + +Map Action ~ + +\r Refreshes the Project fold that the cursor is in by placing in the + fold all the files that match the filter. The Project is refreshed + using an indent of one space for every foldlevel in the hierarchy. + + You may place a "# pragma keep" (without the quotes) at the end of a + line, and the file entry on that line will not be removed when you + refresh. This is useful, for example, when you have . as an entry so + you can easily browse the directory. + + Note that this mapping is actually r, and the default of + || is \. + + This does not work for Projects using |netrw|. + +\R Executes \r recursively in the current fold and all folds below. + This does not work for Projects using |netrw|. + +\c Creates a Project fold entry. It asks for the description, the path + to the files, the CD parameter, and the filename |glob()| pattern. + From this information, it will create the Project Entry below the + cursor. + + This does not work for Projects using |netrw|. + +\C Creates a Project fold entry like \c, but recursively includes all the + subdirectories. + + + Select a file to open in the |CTRL-W_p| window or in a new window. If + the cursor is on a fold, open or close it. + + +\s + Same as but horizontally split the target window. + s is provided for those terminals that don't recognize + . + +\S + Load all files in a project by doing horizontal splits. + + +\o + Same as but ensure that the opened file is the only other + window. o is provided for those terminals that don't + recognize . + + +\v + Same as but only display the file--the cursor stays in the + Project Window. + +<2-LeftMouse> + (Double-click) If on a closed fold, open it. If on an open fold + boundary, close it. If on a filename, open the file in the |CTRL-W_p| + window or in a new window. + + + Same as . + + + Same as . + + + Increase the width of the Project Window by g:proj_window_increment or + toggle between a width of + g:proj_window_width + g:proj_window_increment + and + g:proj_window_width. + + Whether you toggle or monotonically increase the width is determined + by the 't' flag of the g:proj_flags variable (see |project-flags|). + + Note that a Right Mouse click will not automatically place the cursor + in the Project Window if it is in a different window. The window will + go back to the g:proj_window_width width when you leave the window. + + Same as + + +\ + Move the text or fold under the cursor up one row. This may not work + in a terminal because the terminal is unaware of this key combination. + is provided for those terminals that don't recognize + . + + + +\ + Move the text or fold under the cursor down one row. This may not work + in a terminal because the terminal is unaware of this key combination. + is provided for those terminals that don't + recognize . + +\i Show in the status line the completely resolved and inherited + parameters for the fold the cursor is in. This is intended for + debugging your relative path and inherited parameters for manually + entered Projects. + +\I Show in the status line the completely resolved filename. Uses the + Project_GetFname(line('.')) function. + +\1 - \9 + Run the command specified in g:proj_run{x} where {x} is the number + of the key. See the documentation of g:proj_run1 below. + +\f1-\f9 + Run the command specified in g:proj_run_fold{x} where {x} is the + number of the key. The command is run on the files at the current + Project level. See the |project-settings| below. + +\F1-\F9 + Run the command specified in g:proj_run_fold{x} where {x} is the + number of the key. The command is run on the files at the current + Project level and all Subprojects. See the |project-settings| below. + +\0 Display the commands that are defined for \1 through \9. + +\f0 Display the commands that are defined for \f1 through \f9 and \F1 + through \F0. Same as \F0. + +\l Load all the files in the current Project level into Vim. While files + are being loaded, you may press any key to stop. + +\L Load all the files in the current Project and all Subprojects into + Vim. Use this mapping with caution--I wouldn't suggest using \L to + load a Project with thousands of files. (BTW, my Project file has more + than 5,300 files in it!) While files are being loaded, you may press + any key to stop. + +\w Wipe all the files in the current Project level from Vim. (If files + are modified, they will be saved first.) While files are being wiped, + you may press any key to stop. + +\W Wipe all the files in the current Project and all Subprojects from + Vim. (If files are modified, they will be saved first.) While files + are being wiped, you may press any key to stop. + +\g Grep all the files in the current Project level. + +\G Grep all the files in the current Project level and all Subprojects. + +\e Set up the Environment for the Project File as though you had selected + it with . This allows you to do a \e and a :make without + having to open any files in the project. + +\E Explore (using |file-explorer|) the directory of the project the + cursor is in. Does not work with netrw. + + When the 'g' flag is present in g:proj_flags (see |project-flags|) + this key toggles the Project Window open and closed. You may remap + this toggle function by putting the following in your vimrc and + replacing P with whatever key combination you wish: + + nmap P ToggleProject + +Note that the Project Plugin remaps :help because the Help Window and the +Project Window get into a fight over placement. The mapping avoids the +problem. + +============================================================================== +ADDING MAPPINGS *project-adding-mappings* + +You can add your own mappings or change the mappings of the plugin by placing +them in the file $HOME/.vimproject_mappings. This file, if it exists, will be +sourced when the plugin in loaded. Here is an example that will count the +number of entries in a project when you press \K (Kount, C is taken :-): > + + function! s:Wc() + let b:loadcount=0 + function! SpawnExec(infoline, fname, lineno, data) + let b:loadcount = b:loadcount + 1 + if getchar(0) != 0 | let b:stop_everything=1 | endif + endfunction + call Project_ForEach(1, line('.'), "*SpawnExec", 0, '') + delfunction SpawnExec + echon b:loadcount." Files\r" + unlet b:loadcount + if exists("b:stop_everything") + unlet b:stop_everything + echon "Aborted.\r" + endif + endfunction + + nnoremap K :call Wc() + +Here's another example of how I integrated the use of perforce with the plugin +in my $HOME/.vimproject_mappings: +> + function! s:DoP4(cmd) + let name=Project_GetFname(line('.')) + let dir=substitute(name, '\(.*\)/.*', '\1', 'g') + exec 'cd '.dir + exec "!".a:cmd.' '.Project_GetFname(line('.')) + cd - + endfunction + + nmap \pa :call DoP4("p4add") + nmap \pe :call DoP4("p4edit") +< +(Note that I CD to the directory the file is in so I can pick of the $P4CONFIG +file. See the perforce documentation.) + +This creates the mappings \pe to check out the file for edit and \pa to add +the file to the depot. + +Here is another example where I remap the mapping to use an external +program to launch a special kind of file (in this case, it launches ee to view +a jpg file). It is a bit contrived, but it works. +> + let s:sid = substitute(maparg('', 'n'), '.*\(.\{-}\)_.*', '\1', '') + function! s:LaunchOrWhat() + let fname=Project_GetFname(line('.')) + if fname =~ '\.jpg$' + exec 'silent! !ee "'.fname.'"&' + else + call {s:sid}_DoFoldOrOpenEntry('', 'e') + endif + endfunction + nnoremap \|:call LaunchOrWhat() +< +If the file ends in .jpg, the external program is launched, otherwise the +original mapping of is run. + +============================================================================== +SETTINGS *project-settings* + +You can set these variables in your vimrc file before the plugin is loaded to +change its default behavior + +g:proj_window_width + The width of the Project Window that the plugin attempts to maintain. + Default: 24 + + The Project Plugin is not always successful in keeping the window + where I want it with the size specified here, but it does a decent + job. + +g:proj_window_increment + The increment by which to increase the width of the Project Window + when pressing or clicking the . Default: 100 + (See |project-mappings|.) + + *project-flags* +g:proj_flags + Default: "imst" + Various flags to control the behavior of the Project Plugin. This + variable can contain any of the following character flags. + + flag Description ~ + + b When present, use the |browse()| when selecting directories + for \c and \C. This is off by default for Windows, because + the windows browser does not allow you to select directories. + + c When present, the Project Window will automatically close when + you select a file. + + F Float the Project Window. That is, turn off automatic + resizing and placement. This allows placement between other + windows that wish to share similar placement at the side of + the screen. It is also particularly helpful for external + window managers. + + g When present, the mapping for will be created to toggle + the Project Window open and closed. + + i When present, display the filename and the current working + directory in the command line when a file is selected for + opening. + + l When present, the Project Plugin will use the |:lcd| command + rather than |:cd| to change directories when you select a file + to open. This flag is really obsolete and not of much use + because of L below. + + L Similar to l, but install a BufEnter/Leave |:autocommand| to + ensure that the current working directory is changed to the + one specified in the fold CD specification whenever that + buffer is active. (|:lcd| only changes the CWD for a window, + not a buffer.) + + m Turn on mapping of the |CTRL-W_o| and |CTRL-W_CTRL_O| normal + mode commands to make the current buffer the only visible + buffer, but keep the Project Window visible, too. + + n When present, numbers will be turned on for the project + window. + + s When present, the Project Plugin will use syntax highlighting + in the Project Window. + + S Turn on sorting for refresh and create. + + t When present, toggle the size of the window rather than just + increase the size when pressing or right-clicking. + See the entry for in |project-mappings|. + + T When present, put Subproject folds at the top of the fold when + refreshing. + + v When present, use :vimgrep rather than :grep when using \G. + +g:proj_run1 ... g:proj_run9 + Contains a Vim command to execute on the file. See the + mappings of \1 to \9 above. + + %f is replaced with the full path and filename + %F is replaced with the full path and filename with spaces + quoted + %n is replaced with the filename alone + %N is replaced with the filename alone with spaces quoted + %h is replaced with the home directory + %H is replaced with the home directory with spaces quoted + %r is replaced with the directory relative to the CD path + %R is replaced with the directory relative to the CD path + with spaces quoted + %d is replaced with the CD directory. + %D is replaced with the CD directory.with spaces quoted + %% is replaced with a single % that is not used in + expansion. + + (Deprecated: %s is also replaced with the full path and + filename for backward compatibility.) + + For example, gvim will be launched on the file under the + cursor when you enter \3 if the following is in your vimrc + file: > + let g:proj_run3='silent !gvim %f' +< Here are a few other examples: > + let g:proj_run1='!p4 edit %f' + let g:proj_run2='!p4 add %f' + let g:proj_run4="echo 'Viewing %f'|sil !xterm -e less %f &" +< + On Windows systems you will want to put the %f, %h, and %d in + single quotes to avoid \ escaping. + +g:proj_run_fold1 ... g:proj_run_fold9 + Contains a Vim command to execute on the files in a fold. See + the mappings of \f1 to \f9 and \F1 to \F9 above. + + %f is the filename, %h is replaced with the project home + directory, and %d is replaced with the CD directory. Multiple + filenames can be handled in two ways: + + The first (default) way is to have %f replaced with all the + absolute filenames, and the command is run once. The second + is to have the command run for each of the non-absolute + filenames (%f is replaced with one filename at a time). To + select the second behavior, put an '*' character at the + beginning of the g:proj_run_fold{x} variable. (The '*' is + stripped before the command is run.) + + For example, note the difference between the following: > + let g:proj_run_fold3="*echo '%h/%f'" + let g:proj_run_fold4="echo '%f'" +< + Note that on Windows systems, you will want the %f, %h, and %c + within single quotes, or the \ in the paths will cause + problems. The alternative is to put them in |escape()|. + + +============================================================================== +PROJECT EXAMPLE FILE *project-example* + +Here is an example ~/.vimprojects file: > + + 1 My Project=~/c/project CD=. in=in.vim out=out.vim flags=r { + 2 Makefile + 3 in.vim + 4 out.vim + 5 GUI Files=. filter="gui*.c gui*.h" { + 6 gui_window.c + 7 gui_dialog.c + 8 gui_list.c + 9 gui.h # Header file + 10 } + 11 Database Files=. filter="data*.c data*.h" { + 12 data_read.c + 13 data_write.c + 14 data.h + 15 } + 16 OS-Specific Files { + 17 Win32=. filter="os_win32*.c os_win32*.h" { + 18 os_win32_gui.c + 19 os_win32_io.c + 20 } + 21 Unix=. filter="os_unix*.c os_unix*.h" { + 22 os_unix_gui.c + 23 os_unix_io.c + 24 } + 25 } + 26 } + +(Don't type in the line numbers, of course.) + + +============================================================================== +TIPS ON USING PROJECT PLUGIN *project-tips* + +1. You can create a Project Entry by entering this: > + + Label=~/wherever CD=. filter="*.c *.h" { + } +< + Then you can put the cursor in the fold and press \r. The script will fill + in the files (C files in this case) from this directory for you. This is + equivalent to \c without any dialogs. + +2. You can edit the Project File at any time to add, remove, or reorder files + in the Project list. + +3. If the Project Window ever gets closed, you can just enter > + :Project +< to bring it back again. (You don't need to give it the filename; the + plugin remembers.) + + If you have the 'm' flag set in g:proj_flags, then you get the Project + Window to show up again by pressing |CTRL-W_o|. This, of course, will + close any other windows that may be open that the cursor is not in. + +4. Adding files to a Project is very easy. To add, for example, the 'more.c' + file to the Project, just insert the filename in the Project Entry then + hit on it. + +5. When |quickfix| loads files, it is not equivalent to pressing on + a filename, so the directory will not be changed and the scripts will not + be run. (If I could make this otherwise, I would.) The solution is to use + the \L key to load all of the files in the Project before running + quickfix. + +6. If the Project window gets a bit cluttered with folds partially + open/closed, you can press |zM| to close everything and tidy it up. + +7. For advanced users, I am exporting the function Project_GetAllFnames() + which returns all the filenames within a fold and optionally all its + Subprojects. Also, I export Project_ForEach() for running a function for + each filename in the project. See the code for examples on how to use + these. Finally, I export Project_GetFname(line_number) so that you can + write your own mappings and get the filename for it. + +8. Some people have asked how to do a global mapping to take the cursor to + the Project window. One of my goals for the plugin is for it to be as + self-contained as possible, so I'm not going to add it by default. But you + can put this in your vimrc: +> + nmap P :Project + +< +9. You can put the . entry in a project, and it will launch the + |file-explorer| plugin on the directory. To avoid removal when you + refresh, make the entry look like this: +> + . # pragma keep +< +============================================================================== +THANKS + + The following people have sent me patches to help with the Project + Plugin development: + + Tomas Zellerin + Lawrence Kesteloot + Dave Eggum + A Harrison + Thomas Link + Richard Bair + Eric Arnold + Peter Jones + Eric Van Dewoestine + + + vim:ts=8 sw=8 noexpandtab tw=78 ft=help: diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/doc/tags --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/doc/tags Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,72 @@ +:AlignCenter textformat.txt /*:AlignCenter* +:AlignJustify textformat.txt /*:AlignJustify* +:AlignLeft textformat.txt /*:AlignLeft* +:AlignRight textformat.txt /*:AlignRight* +bufexplorer bufexplorer.txt /*bufexplorer* +bufexplorer-changelog bufexplorer.txt /*bufexplorer-changelog* +bufexplorer-credits bufexplorer.txt /*bufexplorer-credits* +bufexplorer-customization bufexplorer.txt /*bufexplorer-customization* +bufexplorer-installation bufexplorer.txt /*bufexplorer-installation* +bufexplorer-todo bufexplorer.txt /*bufexplorer-todo* +bufexplorer-usage bufexplorer.txt /*bufexplorer-usage* +bufexplorer-windowlayout bufexplorer.txt /*bufexplorer-windowlayout* +bufexplorer.txt bufexplorer.txt /*bufexplorer.txt* +buffer-explorer bufexplorer.txt /*buffer-explorer* +drawit DrawIt.txt /*drawit* +drawit-a DrawIt.txt /*drawit-a* +drawit-b DrawIt.txt /*drawit-b* +drawit-brush DrawIt.txt /*drawit-brush* +drawit-c DrawIt.txt /*drawit-c* +drawit-contents DrawIt.txt /*drawit-contents* +drawit-drawing DrawIt.txt /*drawit-drawing* +drawit-e DrawIt.txt /*drawit-e* +drawit-erase DrawIt.txt /*drawit-erase* +drawit-example DrawIt.txt /*drawit-example* +drawit-f DrawIt.txt /*drawit-f* +drawit-history DrawIt.txt /*drawit-history* +drawit-l DrawIt.txt /*drawit-l* +drawit-manual DrawIt.txt /*drawit-manual* +drawit-modes DrawIt.txt /*drawit-modes* +drawit-move DrawIt.txt /*drawit-move* +drawit-moving DrawIt.txt /*drawit-moving* +drawit-options DrawIt.txt /*drawit-options* +drawit-protect DrawIt.txt /*drawit-protect* +drawit-s DrawIt.txt /*drawit-s* +drawit-setbrush DrawIt.txt /*drawit-setbrush* +drawit-setdrawit DrawIt.txt /*drawit-setdrawit* +drawit-start DrawIt.txt /*drawit-start* +drawit-stop DrawIt.txt /*drawit-stop* +drawit-usage DrawIt.txt /*drawit-usage* +drawit-visblock DrawIt.txt /*drawit-visblock* +drawit.txt DrawIt.txt /*drawit.txt* +g:bufExplorerDefaultHelp bufexplorer.txt /*g:bufExplorerDefaultHelp* +g:bufExplorerDetailedHelp bufexplorer.txt /*g:bufExplorerDetailedHelp* +g:bufExplorerFindActive bufexplorer.txt /*g:bufExplorerFindActive* +g:bufExplorerReverseSort bufexplorer.txt /*g:bufExplorerReverseSort* +g:bufExplorerShowDirectories bufexplorer.txt /*g:bufExplorerShowDirectories* +g:bufExplorerShowRelativePath bufexplorer.txt /*g:bufExplorerShowRelativePath* +g:bufExplorerShowTabBuffer bufexplorer.txt /*g:bufExplorerShowTabBuffer* +g:bufExplorerShowUnlisted bufexplorer.txt /*g:bufExplorerShowUnlisted* +g:bufExplorerSortBy bufexplorer.txt /*g:bufExplorerSortBy* +g:bufExplorerSplitBelow bufexplorer.txt /*g:bufExplorerSplitBelow* +g:bufExplorerSplitOutPathName bufexplorer.txt /*g:bufExplorerSplitOutPathName* +g:bufExplorerSplitRight bufexplorer.txt /*g:bufExplorerSplitRight* +g:drawit_insertmode DrawIt.txt /*g:drawit_insertmode* +project project.txt /*project* +project-adding-mappings project.txt /*project-adding-mappings* +project-example project.txt /*project-example* +project-flags project.txt /*project-flags* +project-inheritance project.txt /*project-inheritance* +project-invoking project.txt /*project-invoking* +project-mappings project.txt /*project-mappings* +project-plugin project.txt /*project-plugin* +project-settings project.txt /*project-settings* +project-syntax project.txt /*project-syntax* +project-tips project.txt /*project-tips* +project.txt project.txt /*project.txt* +textformat-commands textformat.txt /*textformat-commands* +textformat-config textformat.txt /*textformat-config* +textformat-history textformat.txt /*textformat-history* +textformat-keymap textformat.txt /*textformat-keymap* +textformat-start textformat.txt /*textformat-start* +textformat.txt textformat.txt /*textformat.txt* diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/doc/textformat.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/doc/textformat.txt Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,301 @@ +*textformat.txt* Vim Text Formatter (version 2.1) 2008-09-13 + + +Description This plugin provides commands and key mappings to quickly + align and format text. Text can be easily reformatted and + aligned to either left or right margin or justified to both + margins or centered. The text formatting commands provided by + this plugin are a bit more automatic and more intelligent than + those integrated to Vim. Together they make more powerful + command set for formatting text. + +Author Teemu Likonen + + + + +Contents + + 1. Quick start |textformat-start| + 2. Commands |textformat-commands| + 3. Default key mappings |textformat-keymap| + 4. Configuration |textformat-config| + 5. Version history |textformat-history| + +============================================================================== +1. Quick start *textformat-start* + +The impatient are always with us so below is a short info on (probably) the +most important tools provided by this plugin. See the following sections of +this manual for more detailed instructions. + +al Left-align and reformat +ar Right-align +aj Left-right justify and reformat +ac Center lines + +In normal mode the commands operate on current paragraph; in visual mode they +operate on the selected lines. By default, is the backslash key, so +the mappings are actually \al, \ar, \aj and \ac, by default. If you have +changed the g:mapleader variable in your .vimrc file may be something +else. + +============================================================================== +2. Commands *textformat-commands* + +Let's start with the basic components of this plugin. These are the ex +commands. You probably don't need these very often but they can be handy if +you want to have text formatting and aligning as a part of a macro or function +or something. The "daily tools" are explained later. + +:[range]AlignLeft [indent] *:AlignLeft* + Align to left all the lines in [range] (default is + current line) and truncate all extra whitespace + characters. That is, if there are more than one space + between words they are reduced to just one. If + 'joinspaces' is set then two spaces are added after + every sentence ending with character ".", "?" or "!". + + If optional numeric argument [indent] is given then + that is used as the left margin. If [indent] is not + given the indent of the first line in the [range] (and + the first line of each paragraph within the [range]) + is used to define indent for the rest of the lines in + the paragraph. There is one exception: if + 'formatoptions' contains "2" then the second line + defines the indent for the rest of the lines in the + paragraph. + + Note: This is very similar to |:left| command except + that this also truncates whitespaces and that without + [indent] each paragraph's indent is detected and used. + + Note: There is a possible unexpected behaviour: If + command is run without [range] (i.e., it's just the + current line) and [indent] is not given then this + command just "aligns" to the current indent position + and truncates whitespaces. You might see nothing + happening if there weren't any extra whitespaces. Use + [indent] (or |:left| command) to align to desired + column. + +:[range]AlignRight [width] *:AlignRight* + Align to right all the lines in [range] (default is + current line) and truncate all extra whitespace + characters (honor 'joinspaces', as in :AlignLeft). + [width] is used as the right margin. If [width] is not + given the value of 'textwidth' option is used instead. + If 'textwidth' is zero then the value of 80 is used. + + Note: This is very similar to |:right| command except + that this also truncates whitespaces. + +:[range]AlignJustify [width] *:AlignJustify* + Left-right justify lines in [range] (default is + current line). This means adjusting spaces between + words so that the lines fit. If 'joinspaces' is set + then at least two spaces are printed after every + sentence ending with a ".", "?" or "!". The first line + in [range] (and the first line in each paragraph + within the [range]) defines the indent for the rest of + the lines in the paragraph, except if 'formatoptions' + contains "2" then it's the second line. + + Numeric argument [width] is used as the right margin. + If [width] is not given the value of 'textwidth' is + used instead. If 'textwidth' is zero then the value of + 80 is used. + + Also see the Discussion below. + +:[range]AlignCenter [width] *:AlignCenter* + Center lines in [range] (default is current line) + between the first column and [width]. All extra + whitespace characters are truncated (but honor + 'joinspaces', just like in :AlignLeft). If [width] is + not given the value of 'textwidth' option is used + instead. If 'textwidth' is zero the value of 80 is + used. + + Note: This is very similar to |:center| except that + this also truncates whitespaces. + + +Discussion ~ + +All the previous ex commands are rather "stupid" and operate on single lines +only. They do not wrap lines nor do other kind of formatting. If [width] (or +'textwidth') is too narrow for the line then some characters will go beyond +the right margin. This is similar to Vim's own |:left|, |:right| and |:center| +commands. More sophisticated formatting tools are provided as key mappings +(see below). + +Usually when paragraphs are justified the last line of each paragraph is +aligned to left. However, :AlignJustify command does not do this. The purpose +of this command is to do exactly what was asked for: left-right justify +a range of lines. More sophisticated justify tools is aj which +reformats the paragraph (like |gw|), justifies lines and aligns each +paragraph's last line to left. + +All the commands truncate extra whitespaces which makes them work well +together. This is particularly because the left-right justify needs to add +extra spaces to make lines fill the text area. If you later want to reformat +such previously justified paragraph and align it to left, for example, it's +convenient that the tool automatically handles this and removes extra spaces. +If you want to align text without truncating whitespaces use Vim's own align +commands: |:left|, |:right| and |:center|. + +============================================================================== +3. Default key mappings *textformat-keymap* + +By default this plugin provides a couple of key mappings for convenient text +formatting. If the mappings have already been defined by user (or are taken by +other plugins) then some of the following mappings may not be automatically +available. See the next section of this manual for information on how to +change the default mappings. + +There are key mappings available for normal mode and visual mode. As usual, + is the backslash key by default but it can be changed with +g:mapleader variable. Consult the Vim manual for more information on . + + +Normal mode (current paragraph) ~ + +al Left-align the current "inner paragraph" (see |ip|) + and reformat it according to 'textwidth'. + +ar Right-align the current "inner paragraph" (see |ip|) + to margin at 'textwidth'. This does not reformat the + paragraph because with right-aligned text user usually + wants to decide exactly what goes to what line. + +aj Left-right justify the current "inner paragraph" (see + |ip|). Technically each line's whitespaces are first + truncated, then the text is reformatted according to + 'textwidth' and finally lines are justified. The last + line (of each text paragraph) is aligned to left. + +ac Center lines of current "inner paragraph" (see |ip|) + between the first column and 'textwidth'. This does + not reformat the paragraph because with centered text + user usually wants to decide exactly what goes to what + line. + + +Visual mode (range of lines) ~ + +{Visual}al Left-align and reformat {Visual} lines so that they + fill 'textwidth'. + +{Visual}ar Right-align {Visual} lines. + +{Visual}aj Left-right justify {Visual} lines. First truncate all + extra whitespace characters, then reformat lines so + that they fill 'textwidth' and finally left-right + justify. The last line of each paragraph as well as + the last line in {Visual} range is aligned to left. + +{Visual}ac Center {Visual} lines. + + +Both normal mode and visual mode commands truncate extra whitespace +characters. If 'joinspaces' is set then an extra space is added after every +sentence ending with a ".", "?" or "!". The first line in each paragraph +inside the range defines the indent for the rest of the lines in the +paragraph, except if 'formatoptions' contains "2" then it's the second line. + + +Paragraph definitions ~ + +The normal mode commands operate on the concept of "inner paragraph" (see +|ip|). The effect is almost the same as selecting current paragraph with Vim's +"vip" command and then executing the equivalent visual mode command. Such +inner paragraph may contain several text paragraphs if 'formatoptions' +contains "w". Each of them is reformatted separately with al and +aj commands. + +New paragraph always begins after a blank line. If 'formatoptions' contains +"w" then new paragraph also begins after a line which ends with +a non-whitespace character. That is, with "w" in 'formatoptions' every line +which ends with a non-whitespace also ends a paragraph. In left-right justify +(aj) such line is aligned to left. You need to ensure that there is +a trailing whitespace in every consecutive line which belongs to same +paragraph (the whitespace is preserved after formatting). If 'formatoptions' +does not contain "w" then all consecutive non-blank lines belong to same +paragraph. + +============================================================================== +4. Configuration *textformat-config* + +The key mappings can be configured freely by user. This plugin uses the +default ones only if they are free and not used for other purposes. Here's an +example of lines you could put to your .vimrc file: +> + nmap Quick_Align_Paragraph_Left + nmap Quick_Align_Paragraph_Right + nmap Quick_Align_Paragraph_Justify + nmap Quick_Align_Paragraph_Center + + vmap Align_Range_Left + vmap Align_Range_Right + vmap Align_Range_Justify + vmap Align_Range_Center + +That is, |:nmap| command defines mappings for normal mode and |:vmap| for +visual mode. Function keys from to are used in this example. The +rest of the line is a code word for Vim and this plugin. They must be written +exactly as shown in the example. I think the code words are pretty much +self-descriptive. + +Don't use |:nnoremap| and |:vnoremap| commands here; they don't work because +the right-hand side (...) must be remappable. See Vim's manual for more +information about the key map commands. + +Most part of this plugin is loaded into memory when the text-formatting +commands or key maps are used for the first time. Only the very minimum is +automatically loaded when Vim is started. If you want to completely avoid +loading this plugin put the following line to your .vimrc file: +> + let g:loaded_textformat = 1 + +Happy formatting! + +============================================================================== +5. Version history *textformat-history* + + v2.1 2008-09-13 + + - Minor internal cleanup. + + v2.0 2008-08-10 + + - \al and \aj now reformat text also in visual mode. + - \al and \aj honor "w" in 'formatoptions' and detect paragraph + boundaries accordingly. + - :AlignLeft, :AlignJustify, \al and \aj recognize several + paragraphs within the range and detect indent for each + paragraph separately. + - Add logic to load the plugin script only once. + + v1.1 2008-08-04 + + - Keep cursor position more accurately when formatting + a paragraph with \al and \aj. + - When 'joinspaces' is set insert two spaces after .?! + punctuation with left-right justify. This is now similar to + other commands. + + v1.0 2008-08-03 + + - All the commands now follow user's 'expandtab' setting and + print leading whitespaces accordingly. Now this works just + like :left, :right and :center commands. + - The left-aligned last line in justified paragraph did not + honor 'joinspaces'. Fixed. + + v0.9 2008-08-01 + + - Initial upload to http://www.vim.org . + +============================================================================== +vim: ft=help tw=78 ts=8 et norl fo+=2aw diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/ftdetect/scala.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/ftdetect/scala.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,3 @@ +" $URL: https://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim/ftdetect/scala.vim $ + +au BufRead,BufNewFile *.scala set filetype=scala diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/indent/scala.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/indent/scala.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,85 @@ +" Vim indent file +" Language : Scala (http://scala-lang.org/) +" Maintainer : Stefan Matthias Aust +" Last Change: 2006 Apr 13 +" Revision : $Id: scala.vim 15234 2008-05-29 21:54:59Z stepancheg $ +" $URL: https://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim/indent/scala.vim $ + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=GetScalaIndent() + +setlocal indentkeys=0{,0},0),!^F,<>>, + +setlocal autoindent sw=2 et + +if exists("*GetScalaIndent") + finish +endif + +function! CountParens(line) + let line = substitute(a:line, '"\(.\|\\"\)*"', '', 'g') + let open = substitute(line, '[^(]', '', 'g') + let close = substitute(line, '[^)]', '', 'g') + return strlen(open) - strlen(close) +endfunction + +function! GetScalaIndent() + " Find a non-blank line above the current line. + let lnum = prevnonblank(v:lnum - 1) + + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + + let ind = indent(lnum) + let prevline = getline(lnum) + + "Indent html literals + if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$' + return ind + &shiftwidth + endif + + " Add a 'shiftwidth' after lines that start a block + " If if, for or while end with ), this is a one-line block + " If val, var, def end with =, this is a one-line block + if prevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\|va[lr]\|def\)\>.*[)=]\s*$' + \ || prevline =~ '^\s*\\s*$' + \ || prevline =~ '{\s*$' + let ind = ind + &shiftwidth + endif + + " If parenthesis are unbalanced, indent or dedent + let c = CountParens(prevline) + echo c + if c > 0 + let ind = ind + &shiftwidth + elseif c < 0 + let ind = ind - &shiftwidth + endif + + " Dedent after if, for, while and val, var, def without block + let pprevline = getline(prevnonblank(lnum - 1)) + if pprevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\|va[lr]\|def\)\>.*[)=]\s*$' + \ || pprevline =~ '^\s*\\s*$' + let ind = ind - &shiftwidth + endif + + " Align 'for' clauses nicely + if prevline =~ '^\s*\ (.*;\s*$' + let ind = ind - &shiftwidth + 5 + endif + + " Subtract a 'shiftwidth' on '}' or html + let thisline = getline(v:lnum) + if thisline =~ '^\s*[})]' + \ || thisline =~ '^\s*]*>' + let ind = ind - &shiftwidth + endif + + return ind +endfunction diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/plugin/31-create-scala.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/plugin/31-create-scala.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,57 @@ +" Vim plugin that generates new Scala source file when you type +" vim nonexistent.scala. +" Scripts tries to detect package name from the directory path, e. g. +" .../src/main/scala/com/mycompany/myapp/app.scala gets header +" package com.mycompany.myapp +" +" Author : Stepan Koltsov +" Revision : $Id: 31-create-scala.vim 17312 2009-03-16 04:02:05Z stepancheg $ +" $URL: https://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim/plugin/31-create-scala.vim $ + +function! MakeScalaFile() + if exists("b:template_used") && b:template_used + return + endif + + let b:template_used = 1 + + let filename = expand(":p") + let x = substitute(filename, "\.scala$", "", "") + + let p = substitute(x, "/[^/]*$", "", "") + let p = substitute(p, "/", ".", "g") + let p = substitute(p, ".*\.src$", "@", "") " unnamed package + let p = substitute(p, ".*\.src\.", "!", "") + let p = substitute(p, "^!main\.scala\.", "!", "") " + let p = substitute(p, "^!.*\.ru\.", "!ru.", "") + let p = substitute(p, "^!.*\.org\.", "!org.", "") + let p = substitute(p, "^!.*\.com\.", "!com.", "") + + " ! marks that we found package name. + if match(p, "^!") == 0 + let p = substitute(p, "^!", "", "") + else + " Don't know package name. + let p = "@" + endif + + let class = substitute(x, ".*/", "", "") + + if p != "@" + call append("0", "package " . p) + endif + + "norm G + "call append(".", "class " . class . " {") + + "norm G + "call append(".", "} /// end of " . class) + + call append(".", "// vim: set ts=2 sw=2 et:") + call append(".", "") + +endfunction + +au BufNewFile *.scala call MakeScalaFile() + +" vim: set ts=4 sw=4 et: diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/plugin/DrawItPlugin.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/plugin/DrawItPlugin.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,65 @@ +" DrawItPlugin.vim: a simple way to draw things in Vim -- just put this file in +" your plugin directory, use \di to start (\ds to stop), and +" just move about using the cursor keys. +" +" You may also use visual-block mode to select endpoints and +" draw lines, arrows, and ellipses. +" +" Date: Jul 18, 2006 +" Maintainer: Charles E. Campbell, Jr. (Charles.E.Campbell.1@gsfc.nasa.gov) +" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" DrawIt.vim is provided *as is* and comes with no warranty +" of any kind, either expressed or implied. By using this +" plugin, you agree that in no event will the copyright +" holder be liable for any damages resulting from the use +" of this software. +" +" Required: this script requires Vim 7.0 (or later) {{{1 +" To Enable: simply put this plugin into your ~/.vim/plugin directory {{{2 +" +" GetLatestVimScripts: 40 1 :AutoInstall: DrawIt.vim +" +" (Zeph 3:1,2 WEB) Woe to her who is rebellious and polluted, the {{{1 +" oppressing city! She didn't obey the voice. She didn't receive +" correction. She didn't trust in Yahweh. She didn't draw near to her God. + +" --------------------------------------------------------------------- +" Load Once: {{{1 +if &cp || exists("g:loaded_DrawItPlugin") + finish +endif +let g:loaded_DrawItPlugin = 1 +let s:keepcpo = &cpo +set cpo&vim + +" --------------------------------------------------------------------- +" DrChip Menu Support: {{{1 +if has("gui_running") && has("menu") && &go =~ 'm' + if !exists("g:DrChipTopLvlMenu") + let g:DrChipTopLvlMenu= "DrChip." + endif + exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt\\di di' +endif + +" --------------------------------------------------------------------- +" Public Interface: {{{1 +if !hasmapto('StartDrawIt') + map di StartDrawIt +endif +map StartDrawIt :set lz:call DrawIt#StartDrawIt():set nolz +com! -nargs=0 DIstart set lz|call DrawIt#StartDrawIt()|set nolz + +if !hasmapto('StopDrawIt') + map ds StopDrawIt +endif +map StopDrawIt :set lz:call DrawIt#StopDrawIt():set nolz +com! -nargs=0 DIstop set lz|call DrawIt#StopDrawIt()|set nolz + +" --------------------------------------------------------------------- +" Cleanup And Modelines: +" vim: fdm=marker +let &cpo= s:keepcpo +unlet s:keepcpo diff -r ebfb86eb9718 -r ca6892f0a9e8 config/.vim/plugin/bufexplorer.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/.vim/plugin/bufexplorer.vim Tue May 03 08:57:01 2011 +0200 @@ -0,0 +1,1140 @@ +"============================================================================== +" Copyright: Copyright (C) 2001-2010 Jeff Lanzarotta +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" bufexplorer.vim is provided *as is* and comes with no +" warranty of any kind, either expressed or implied. In no +" event will the copyright holder be liable for any damages +" resulting from the use of this software. +" Name Of File: bufexplorer.vim +" Description: Buffer Explorer Vim Plugin +" Maintainer: Jeff Lanzarotta (delux256-vim at yahoo dot com) +" Last Changed: Tuesday, 16 Feb 2010 +" Version: See g:bufexplorer_version for version number. +" Usage: This file should reside in the plugin directory and be +" automatically sourced. +" +" You may use the default keymappings of +" +" be - Opens BE. +" bs - Opens horizontally window BE. +" bv - Opens vertically window BE. +" +" Or you can use +" +" ":BufExplorer" - Opens BE. +" ":BufExplorerHorizontalSplit" - Opens horizontally window BE. +" ":BufExplorerVerticalSplit" - Opens vertically window BE. +" +" For more help see supplied documentation. +" History: See supplied documentation. +"============================================================================== + +" Exit quickly if already running or when 'compatible' is set. {{{1 +if exists("g:bufexplorer_version") || &cp + finish +endif +"1}}} + +" Version number +let g:bufexplorer_version = "7.2.7" + +" Check for Vim version 700 or greater {{{1 +if v:version < 700 + echo "Sorry, bufexplorer ".g:bufexplorer_version."\nONLY runs with Vim 7.0 and greater." + finish +endif + +" Public Interface {{{1 +if maparg("be") =~ 'BufExplorer' + nunmap be +endif + +if maparg("bs") =~ 'BufExplorerHorizontalSplit' + nunmap bs +endif + +if maparg("bv") =~ 'BufExplorerVerticalSplit' + nunmap bv +endif + +nmap