GetLatestVimscripts

git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@171 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
stefan 2008-10-30 08:14:42 +00:00
parent 5919dd2bca
commit 1ef6705fdb
14 changed files with 3959 additions and 3576 deletions

View File

@ -1,7 +1,7 @@
" Align: tool to align multiple fields based on one or more separators
" Author: Charles E. Campbell, Jr.
" Date: Mar 06, 2008
" Version: 33
" Date: Oct 08, 2008
" Version: 34
" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
@ -24,19 +24,23 @@
if exists("g:loaded_align") || &cp
finish
endif
let g:loaded_align = "v33"
let s:keepcpo = &cpo
let g:loaded_align = "v34"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of Align needs vim 7.0"
echohl Normal
finish
endif
let s:keepcpo= &cpo
set cpo&vim
"DechoTabOn
" ---------------------------------------------------------------------
" Debugging Support:
"if !exists("g:loaded_Decho") "Decho
" runtime plugin/Decho.vim
"endif " Decho
"if !exists("g:loaded_Decho") | runtime plugin/Decho.vim | endif
" ---------------------------------------------------------------------
" AlignCtrl: enter alignment patterns here {{{1
" Align#AlignCtrl: enter alignment patterns here {{{1
"
" Styles = all alignment-break patterns are equivalent
" C cycle through alignment-break pattern(s)
@ -135,6 +139,9 @@ fun! Align#AlignCtrl(...)
" ----------------------
" List current selection
" ----------------------
if !exists("s:AlignPatQty")
let s:AlignPatQty= 0
endif
echo "AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep
" call Decho("AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep)
if exists("s:AlignGPat") && !exists("s:AlignVPat")
@ -308,7 +315,7 @@ fun! Align#AlignCtrl(...)
endfun
" ---------------------------------------------------------------------
" MakeSpace: returns a string with spacecnt blanks {{{1
" s:MakeSpace: returns a string with spacecnt blanks {{{1
fun! s:MakeSpace(spacecnt)
" call Dfunc("MakeSpace(spacecnt=".a:spacecnt.")")
let str = ""
@ -448,8 +455,8 @@ fun! Align#Align(hasctrl,...) range
" call Decho("lines[".begline.",".endline."] col[".begcol.",".endcol."] ragged=".ragged." AlignCtrl<".s:AlignCtrl.">")
" Keep user options
let etkeep = &et
let pastekeep= &paste
let etkeep = &l:et
let pastekeep= &l:paste
setlocal et paste
" convert selected range of lines to use spaces instead of tabs
@ -735,8 +742,8 @@ fun! Align#Align(hasctrl,...) range
" call Decho("end of two pass loop")
" Restore user options
let &et = etkeep
let &paste = pastekeep
let &l:et = etkeep
let &l:paste = pastekeep
if exists("s:DoAlignPop")
" AlignCtrl Map support
@ -754,7 +761,7 @@ fun! Align#Align(hasctrl,...) range
endfun
" ---------------------------------------------------------------------
" AlignPush: this command/function pushes an alignment control string onto a stack {{{1
" Align#AlignPush: this command/function pushes an alignment control string onto a stack {{{1
fun! Align#AlignPush()
" call Dfunc("AlignPush()")
@ -788,7 +795,7 @@ fun! Align#AlignPush()
endfun
" ---------------------------------------------------------------------
" AlignPop: this command/function pops an alignment pattern from a stack {{1
" Align#AlignPop: this command/function pops an alignment pattern from a stack {{{1
" and into the AlignCtrl variables.
fun! Align#AlignPop()
" call Dfunc("Align#AlignPop()")
@ -834,7 +841,7 @@ fun! Align#AlignPop()
endfun
" ---------------------------------------------------------------------
" AlignReplaceQuotedSpaces: {{{1
" Align#AlignReplaceQuotedSpaces: {{{1
fun! Align#AlignReplaceQuotedSpaces()
" call Dfunc("AlignReplaceQuotedSpaces()")
@ -957,7 +964,7 @@ endfun
" ---------------------------------------------------------------------
" s:Strlen: this function returns the length of a string, even if its {{{1
" using two-byte etc characters. Depends on virtcol().
" using two-byte etc characters.
" Currently, its only used if g:Align_xstrlen is set to a
" nonzero value. Solution from Nicolai Weibull, vim docs
" (:help strlen()), Tony Mechelynck, and my own invention.

View File

@ -0,0 +1,330 @@
" AlignMaps.vim : support functions for AlignMaps
" Author: Charles E. Campbell, Jr.
" Date: Oct 24, 2008
" Version: 40
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_AlignMaps")
finish
endif
let g:loaded_AlignMaps= "v40"
let s:keepcpo = &cpo
set cpo&vim
" =====================================================================
" Functions: {{{1
" ---------------------------------------------------------------------
" AlignMaps#WrapperStart: {{{2
fun! AlignMaps#WrapperStart(vis)
" call Dfunc("AlignMaps#WrapperStart(vis=".a:vis.")")
if a:vis
norm! '<ma'>
endif
if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0
" call Decho("wrapper initialization")
let s:alignmaps_wrapcnt = 1
let s:alignmaps_keepgd = &gdefault
let s:alignmaps_keepsearch = @/
let s:alignmaps_keepch = &ch
let s:alignmaps_keepmy = SaveMark("'y")
let s:alignmaps_keepmz = SaveMark("'z")
let s:alignmaps_posn = SaveWinPosn(0)
" set up fencepost blank lines
put =''
norm! mz'a
put! =''
ky
let s:alignmaps_zline = line("'z")
exe "'y,'zs/@/\177/ge"
else
" call Decho("embedded wrapper")
let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1
norm! 'yjma'zk
endif
" change some settings to align-standard values
set nogd
set ch=2
AlignPush
norm! 'zk
" call Dret("AlignMaps#WrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
endfun
" ---------------------------------------------------------------------
" AlignMaps#WrapperEnd: {{{2
fun! AlignMaps#WrapperEnd()
" call Dfunc("AlignMaps#WrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
" remove trailing white space introduced by whatever in the modification zone
'y,'zs/ \+$//e
" restore AlignCtrl settings
AlignPop
let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1
if s:alignmaps_wrapcnt <= 0
" initial wrapper ending
exe "'y,'zs/\177/@/ge"
" if the 'z line hasn't moved, then go ahead and restore window position
let zstationary= s:alignmaps_zline == line("'z")
" remove fencepost blank lines.
" restore 'a
norm! 'yjmakdd'zdd
" restore original 'y, 'z, and window positioning
call RestoreMark(s:alignmaps_keepmy)
call RestoreMark(s:alignmaps_keepmz)
if zstationary > 0
call RestoreWinPosn(s:alignmaps_posn)
" call Decho("restored window positioning")
endif
" restoration of options
let &gd= s:alignmaps_keepgd
let &ch= s:alignmaps_keepch
let @/ = s:alignmaps_keepsearch
" remove script variables
unlet s:alignmaps_keepch
unlet s:alignmaps_keepsearch
unlet s:alignmaps_keepmy
unlet s:alignmaps_keepmz
unlet s:alignmaps_keepgd
unlet s:alignmaps_posn
endif
" call Dret("AlignMaps#WrapperEnd : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
endfun
" ---------------------------------------------------------------------
" AlignMaps#StdAlign: some semi-standard align calls {{{2
fun! AlignMaps#StdAlign(mode)
" call Dfunc("AlignMaps#StdAlign(mode=".a:mode.")")
if a:mode == 1
" align on @
" call Decho("align on @")
AlignCtrl mIp1P1=l @
'a,.Align
elseif a:mode == 2
" align on @, retaining all initial white space on each line
" call Decho("align on @, retaining all initial white space on each line")
AlignCtrl mWp1P1=l @
'a,.Align
elseif a:mode == 3
" like mode 2, but ignore /* */-style comments
" call Decho("like mode 2, but ignore /* */-style comments")
AlignCtrl v ^\s*/[/*]
AlignCtrl mWp1P1=l @
'a,.Align
else
echoerr "(AlignMaps) AlignMaps#StdAlign doesn't support mode#".a:mode
endif
" call Dret("AlignMaps#StdAlign")
endfun
" ---------------------------------------------------------------------
" AlignMaps#CharJoiner: joins lines which end in the given character (spaces {{{2
" at end are ignored)
fun! AlignMaps#CharJoiner(chr)
" call Dfunc("AlignMaps#CharJoiner(chr=".a:chr.")")
let aline = line("'a")
let rep = line(".") - aline
while rep > 0
norm! 'a
while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0
" while = at end-of-line, delete it and join with next
norm! 'a$
j!
let rep = rep - 1
endwhile
" update rep(eat) count
let rep = rep - 1
if rep <= 0
" terminate loop if at end-of-block
break
endif
" prepare for next line
norm! jma
let aline = line("'a")
endwhile
" call Dret("AlignMaps#CharJoiner")
endfun
" ---------------------------------------------------------------------
" AlignMaps#Equals: supports \t= and \T= {{{2
fun! AlignMaps#Equals()
" call Dfunc("AlignMaps#Equals()")
'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e
'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge
'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge
'a,'zs/!=/\="!\<Char-0xff>"/ge
norm g'zk
AlignCtrl mIp1P1=l =
AlignCtrl g =
'a,'z-1Align
'a,'z-1s@\([*/+\-%|&\~^!=]\)\( \+\)=@\2\1=@ge
'a,'z-1s/\( \+\);/;\1/ge
if &ft == "c" || &ft == "cpp"
" call Decho("exception for ".&ft)
'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e
'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e
if exists("g:mapleader")
exe "norm 'zk"
call AlignMaps#StdAlign(1)
else
exe "norm 'zk"
call AlignMaps#StdAlign(1)
endif
'y,'zs/^\(\s*\) @/\1/e
endif
'a,'z-1s/\%xff/=/ge
'y,'zs/ @//eg
" call Dret("AlignMaps#Equals")
endfun
" ---------------------------------------------------------------------
" AlignMaps#Afnc: useful for splitting one-line function beginnings {{{2
" into one line per argument format
fun! AlignMaps#Afnc()
" call Dfunc("AlignMaps#Afnc()")
" keep display quiet
let chkeep = &ch
let gdkeep = &gd
let vekeep = &ve
set ch=2 nogd ve=
" will use marks y,z ; save current values
let mykeep = SaveMark("'y")
let mzkeep = SaveMark("'z")
" Find beginning of function -- be careful to skip over comments
let cmmntid = synIDtrans(hlID("Comment"))
let stringid = synIDtrans(hlID("String"))
exe "norm! ]]"
while search(")","bW") != 0
" call Decho("line=".line(".")." col=".col("."))
let parenid= synIDtrans(synID(line("."),col("."),1))
if parenid != cmmntid && parenid != stringid
break
endif
endwhile
norm! %my
s/(\s*\(\S\)/(\r \1/e
exe "norm! `y%"
s/)\s*\(\/[*/]\)/)\r\1/e
exe "norm! `y%mz"
'y,'zs/\s\+$//e
'y,'zs/^\s\+//e
'y+1,'zs/^/ /
" insert newline after every comma only one parenthesis deep
sil! exe "norm! `y\<right>h"
let parens = 1
let cmmnt = 0
let cmmntline= -1
while parens >= 1
" call Decho("parens=".parens." @a=".@a)
exe 'norm! ma "ay`a '
if @a == "("
let parens= parens + 1
elseif @a == ")"
let parens= parens - 1
" comment bypass: /* ... */ or //...
elseif cmmnt == 0 && @a == '/'
let cmmnt= 1
elseif cmmnt == 1
if @a == '/'
let cmmnt = 2 " //...
let cmmntline= line(".")
elseif @a == '*'
let cmmnt= 3 " /*...
else
let cmmnt= 0
endif
elseif cmmnt == 2 && line(".") != cmmntline
let cmmnt = 0
let cmmntline= -1
elseif cmmnt == 3 && @a == '*'
let cmmnt= 4
elseif cmmnt == 4
if @a == '/'
let cmmnt= 0 " ...*/
elseif @a != '*'
let cmmnt= 3
endif
elseif @a == "," && parens == 1 && cmmnt == 0
exe "norm! i\<CR>\<Esc>"
endif
endwhile
norm! `y%mz%
sil! 'y,'zg/^\s*$/d
" perform substitutes to mark fields for Align
sil! 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e
sil! 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg
sil! 'y+1,'zv/^\//s/\* \+/*/ge
sil! 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge
" func
" ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end->
sil! 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e
sil! 'y+1,'z+1g/^\s*\/[*/]/norm! kJ
sil! 'y+1,'z+1s%/[*/]%@&@%ge
sil! 'y+1,'z+1s%*/%@&%ge
AlignCtrl mIp0P0=l @
sil! 'y+1,'zAlign
sil! 'y,'zs%@\(/[*/]\)@%\t\1 %e
sil! 'y,'zs%@\*/% */%e
sil! 'y,'zs/@\([,)]\)/\1/
sil! 'y,'zs/@/ /
AlignCtrl mIlrp0P0= # @
sil! 'y+1,'zAlign
sil! 'y+1,'zs/#/ /
sil! 'y+1,'zs/@//
sil! 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e
" Restore
call RestoreMark(mykeep)
call RestoreMark(mzkeep)
let &ch= chkeep
let &gd= gdkeep
let &ve= vekeep
" call Dret("AlignMaps#Afnc")
endfun
" ---------------------------------------------------------------------
" AlignMaps#FixMultiDec: converts a type arg,arg,arg; line to multiple lines {{{2
fun! AlignMaps#FixMultiDec()
" call Dfunc("AlignMaps#FixMultiDec()")
" save register x
let xkeep = @x
let curline = getline(".")
" call Decho("curline<".curline.">")
" Get the type. I'm assuming one type per line (ie. int x; double y; on one line will not be handled properly)
let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9_ \t]*\)\s\+[(*]*\h.*$','\1','')
" call Decho("@x<".@x.">")
" transform line
exe 's/,/;\r'.@x.' /ge'
"restore register x
let @x= xkeep
" call Dret("AlignMaps#FixMultiDec : my=".line("'y")." mz=".line("'z"))
endfun
" ---------------------------------------------------------------------
" Restore: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" vim: ts=4 fdm=marker

View File

@ -1,7 +1,7 @@
" netrw.vim: Handles file transfer and remote directory listing across
" AUTOLOAD SECTION
" Date: Sep 02, 2008
" Version: 133
" Date: Oct 23, 2008
" Version: 134
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 1999-2008 Charles E. Campbell, Jr. {{{1
@ -22,12 +22,18 @@
if &cp || exists("g:loaded_netrw")
finish
endif
let g:loaded_netrw = "v134"
if v:version < 702
echohl WarningMsg
echo "***warning*** this version of netrw needs vim 7.2"
echohl Normal
finish
endif
if !exists("s:NOTE")
let s:NOTE = 0
let s:WARNING = 1
let s:ERROR = 2
endif
let g:loaded_netrw = "v133"
" sanity checks
if v:version < 700
@ -46,11 +52,8 @@ setlocal cpo&vim
" ---------------------------------------------------------------------
" Netrw Constants: {{{2
if !exists("g:NETRW_BOOKMARKMAX")
let g:NETRW_BOOKMARKMAX= 0
endif
if !exists("g:NETRW_DIRHIST_CNT")
let g:NETRW_DIRHIST_CNT= 0
if !exists("g:netrw_dirhist_cnt")
let g:netrw_dirhist_cnt= 0
endif
if !exists("s:LONGLIST")
let s:THINLIST = 0
@ -63,7 +66,13 @@ endif
" ---------------------------------------------------------------------
" Default values for netrw's global protocol variables {{{2
if !exists("g:netrw_dav_cmd")
if executable("cadaver")
let g:netrw_dav_cmd = "cadaver"
elseif executable("curl")
let g:netrw_dav_cmd = "curl"
else
let g:netrw_dav_cmd = ""
endif
endif
if !exists("g:netrw_fetch_cmd")
if executable("fetch")
@ -78,16 +87,29 @@ endif
if !exists("g:netrw_http_cmd")
if executable("elinks")
let g:netrw_http_cmd = "elinks"
let g:netrw_http_xcmd= "-dump >"
if !exists("g:netrw_http_xcmd")
let g:netrw_http_xcmd= "-dump >"
endif
elseif executable("links")
let g:netrw_http_cmd = "links"
let g:netrw_http_xcmd= "-dump >"
if !exists("g:netrw_http_xcmd")
let g:netrw_http_xcmd= "-dump >"
endif
elseif executable("curl")
let g:netrw_http_cmd = "curl -o"
let g:netrw_http_cmd = "curl"
if !exists("g:netrw_http_xcmd")
let g:netrw_http_xcmd= "-o"
endif
elseif executable("wget")
let g:netrw_http_cmd = "wget -q -O"
let g:netrw_http_cmd = "wget"
if !exists("g:netrw_http_xcmd")
let g:netrw_http_xcmd= "-q -O"
endif
elseif executable("fetch")
let g:netrw_http_cmd = "fetch -o"
let g:netrw_http_cmd = "fetch"
if !exists("g:netrw_http_xcmd")
let g:netrw_http_xcmd= "-o"
endif
else
let g:netrw_http_cmd = ""
endif
@ -158,8 +180,8 @@ if !exists("g:netrw_cursorline")
let s:netrw_usercuc = &cursorcolumn
endif
" Default values - d-g ---------- {{{3
if !exists("g:NETRW_DIRHIST_CNT")
let g:NETRW_DIRHIST_CNT= 0
if !exists("g:netrw_dirhist_cnt")
let g:netrw_dirhist_cnt= 0
endif
if !exists("g:netrw_decompress")
let g:netrw_decompress= { ".gz" : "gunzip" , ".bz2" : "bunzip2" , ".zip" : "unzip" , ".tar" : "tar -xf"}
@ -518,6 +540,7 @@ fun! s:NetrwSafeOptions()
setlocal fo=nroql2
setlocal tw=0
setlocal report=10000
setlocal isk+=@ isk+=* isk+=/
if g:netrw_use_noswf && has("win32") && !has("win95")
setlocal noswf
endif
@ -873,28 +896,38 @@ fun! netrw#NetRead(mode,...)
setlocal ro
".........................................
" cadaver: NetRead Method #6 {{{3
" dav: NetRead Method #6 {{{3
elseif b:netrw_method == 6
" call Decho("read via cadaver (method #6)")
" Construct execution string (four lines) which will be passed through filter
let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
new
setlocal ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
put ='open '.g:netrw_machine.' '.g:netrw_port
else
put ='open '.g:netrw_machine
if !executable(g:netrw_dav_cmd)
call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73)
" call Dret("netrw#NetRead : ".g:netrw_dav_cmd." not executable")
return
endif
put ='user '.g:netrw_uid.' '.s:netrw_passwd
put ='get '.netrw_fname.' '.tmpfile
put ='quit'
if g:netrw_dav_cmd =~ "curl"
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1))
exe s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1)
else
" Construct execution string (four lines) which will be passed through filter
let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
new
setlocal ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
put ='open '.g:netrw_machine.' '.g:netrw_port
else
put ='open '.g:netrw_machine
endif
put ='user '.g:netrw_uid.' '.s:netrw_passwd
put ='get '.netrw_fname.' '.tmpfile
put ='quit'
" perform cadaver operation:
norm! 1Gdd
" perform cadaver operation:
norm! 1Gdd
" call Decho("executing: %!".g:netrw_dav_cmd)
exe s:netrw_silentxfer."%!".g:netrw_dav_cmd
bd!
exe s:netrw_silentxfer."%!".g:netrw_dav_cmd
bd!
endif
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
@ -1444,7 +1477,7 @@ endfun
" 3: ftp + machine, id, password, and [path]filename
" 4: scp
" 5: http (wget)
" 6: cadaver
" 6: dav
" 7: rsync
" 8: fetch
" 9: sftp
@ -1479,7 +1512,7 @@ fun! s:NetrwMethod(choice)
" rcphf : [user@]host:filename Use rcp
" scpurm : scp://[user@]host[[#:]port]/filename Use scp
" httpurm : http://[user@]host/filename Use wget
" davurm : dav[s]://host[:port]/path Use cadaver
" davurm : dav[s]://host[:port]/path Use cadaver/curl
" rsyncurm : rsync://host[:port]/path Use rsync
" fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)
" sftpurm : sftp://[user@]host/filename Use scp
@ -1726,7 +1759,7 @@ fun! s:BrowserMaps(islocal)
nnoremap <buffer> <silent> <cr> :call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,'../'))<cr>
nnoremap <buffer> <silent> a :call <SID>NetrwHide(1)<cr>
nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookmarkDir(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mc :<c-u>call <SID>NetrwMarkFileCopy(1)<cr>
nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(1)<cr>
nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(1)<cr>
@ -1742,7 +1775,7 @@ fun! s:BrowserMaps(islocal)
nnoremap <buffer> <silent> mu :<c-u>call <SID>NetrwUnMarkFile(1)<cr>
nnoremap <buffer> <silent> mx :<c-u>call <SID>NetrwMarkFileExe(1)<cr>
nnoremap <buffer> <silent> mz :<c-u>call <SID>NetrwMarkFileCompress(1)<cr>
nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookmarkDir(1,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> gh :<c-u>call <SID>NetrwHidden(1)<cr>
nnoremap <buffer> <silent> c :exe "keepjumps lcd ".fnameescape(b:netrw_curdir)<cr>
nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
@ -1752,15 +1785,15 @@ fun! s:BrowserMaps(islocal)
nnoremap <buffer> <silent> O :call <SID>NetrwObtain(1)<cr>
nnoremap <buffer> <silent> p :call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(1)<cr>
nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookmarkDir(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookmarkDir(6,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(1)<cr>
nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr>
nnoremap <buffer> <silent> t :call <SID>NetrwSplit(4)<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookmarkDir(4,expand("%"))<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookmarkDir(5,expand("%"))<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr>
nnoremap <buffer> <silent> v :call <SID>NetrwSplit(5)<cr>
nnoremap <buffer> <silent> x :call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(1)<cr>
@ -1802,7 +1835,7 @@ fun! s:BrowserMaps(islocal)
nnoremap <buffer> <silent> <c-l> :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'../'))<cr>
nnoremap <buffer> <silent> a :call <SID>NetrwHide(0)<cr>
nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookmarkDir(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mc :<c-u>call <SID>NetrwMarkFileCopy(0)<cr>
nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(0)<cr>
nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(0)<cr>
@ -1818,7 +1851,7 @@ fun! s:BrowserMaps(islocal)
nnoremap <buffer> <silent> mu :<c-u>call <SID>NetrwUnMarkFile(0)<cr>
nnoremap <buffer> <silent> mx :<c-u>call <SID>NetrwMarkFileExe(0)<cr>
nnoremap <buffer> <silent> mz :<c-u>call <SID>NetrwMarkFileCompress(0)<cr>
nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookmarkDir(1,b:netrw_cur)<cr>
nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_cur)<cr>
nnoremap <buffer> <silent> gh :<c-u>call <SID>NetrwHidden(0)<cr>
nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
nnoremap <buffer> <silent> i :call <SID>NetrwListStyle(0)<cr>
@ -1826,15 +1859,15 @@ fun! s:BrowserMaps(islocal)
nnoremap <buffer> <silent> O :call <SID>NetrwObtain(0)<cr>
nnoremap <buffer> <silent> p :call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(0)<cr>
nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookmarkDir(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookmarkDir(6,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(0)<cr>
nnoremap <buffer> <silent> S :call <SID>NetSortSequence(0)<cr>
nnoremap <buffer> <silent> t :call <SID>NetrwSplit(1)<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookmarkDir(4,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookmarkDir(5,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> v :call <SID>NetrwSplit(2)<cr>
nnoremap <buffer> <silent> x :call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr>
nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(0)<cr>
@ -1884,7 +1917,7 @@ fun! s:ExplorePatHls(pattern)
endfun
" ---------------------------------------------------------------------
" s:NetrwBookmarkDir: {{{2
" s:NetrwBookHistHandler: {{{2
" 0: (user: <mb>) bookmark current directory
" 1: (user: <gb>) change to the bookmarked directory
" 2: (user: <qb>) list bookmarks
@ -1892,32 +1925,27 @@ endfun
" 4: (user: <u>) go up (previous) bookmark
" 5: (user: <U>) go down (next) bookmark
" 6: (user: <mB>) delete bookmark
fun! s:NetrwBookmarkDir(chg,curdir)
" call Dfunc("NetrwBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." bookmax=".g:NETRW_BOOKMARKMAX." histmax=".g:netrw_dirhistmax)
fun! s:NetrwBookHistHandler(chg,curdir)
" call Dfunc("NetrwBookHistHandler(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." histcnt=".g:netrw_dirhist_cnt." histmax=".g:netrw_dirhistmax)
if a:chg == 0
" bookmark the current directory
" call Decho("(user: <b>) bookmark the current directory")
if v:count > 0
" handle bookmark# specified via the count
let g:NETRW_BOOKMARKDIR_{v:count}= a:curdir
if !exists("g:NETRW_BOOKMARKMAX")
let g:NETRW_BOOKMARKMAX= v:count
elseif v:count > g:NETRW_BOOKMARKMAX
let g:NETRW_BOOKMARKMAX= v:count
endif
else
" handle no count specified
let g:NETRW_BOOKMARKMAX = g:NETRW_BOOKMARKMAX + 1
let g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX} = a:curdir
if !exists("g:netrw_bookmarklist")
let g:netrw_bookmarklist= []
endif
if index(g:netrw_bookmarklist,a:curdir) == -1
" curdir not currently in g:netrw_bookmarklist, so include it
call add(g:netrw_bookmarklist,a:curdir)
call sort(g:netrw_bookmarklist)
endif
echo "bookmarked the current directory"
elseif a:chg == 1
" change to the bookmarked directory
" call Decho("(user: <B>) change to the bookmarked directory")
if exists("g:NETRW_BOOKMARKDIR_{v:count}")
exe "e ".fnameescape(g:NETRW_BOOKMARKDIR_{v:count})
" call Decho("(user: <".v:count."mb>) change to the bookmarked directory")
if exists("g:netrw_bookmarklist[v:count-1]")
exe "e ".fnameescape(g:netrw_bookmarklist[v:count-1])
else
echomsg "Sorry, bookmark#".v:count." doesn't exist!"
endif
@ -1927,29 +1955,27 @@ fun! s:NetrwBookmarkDir(chg,curdir)
let didwork= 0
" list user's bookmarks
" call Decho("(user: <q>) list user's bookmarks")
if exists("g:NETRW_BOOKMARKMAX")
" call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]")
let cnt= 0
while cnt <= g:NETRW_BOOKMARKMAX
if exists("g:NETRW_BOOKMARKDIR_{cnt}")
" call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt})
echo "Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt}
let didwork= 1
endif
let cnt= cnt + 1
endwhile
if exists("g:netrw_bookmarklist")
" call Decho('list '.len(g:netrw_bookmarklist).' bookmarks')
let cnt= 1
for bmd in g:netrw_bookmarklist
" call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1])
echo "Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1]
let didwork = 1
let cnt = cnt + 1
endfor
endif
" list directory history
let cnt = g:NETRW_DIRHIST_CNT
let cnt = g:netrw_dirhist_cnt
let first = 1
let histcnt = 0
while ( first || cnt != g:NETRW_DIRHIST_CNT )
" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:NETRW_DIRHIST_CNT)
while ( first || cnt != g:netrw_dirhist_cnt )
" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:netrw_dirhist_cnt)
let histcnt= histcnt + 1
if exists("g:NETRW_DIRHIST_{cnt}")
" call Decho("Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt})
echo "Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt}
if exists("g:netrw_dirhist_{cnt}")
" call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt})
echo "Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt}
let didwork= 1
endif
let first = 0
@ -1965,22 +1991,21 @@ fun! s:NetrwBookmarkDir(chg,curdir)
elseif a:chg == 3
" saves most recently visited directories (when they differ)
" call Decho("(browsing) record curdir history")
if !exists("g:NETRW_DIRHIST_0") || g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} != a:curdir
let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
" let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e')
let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= a:curdir
" call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
if !exists("g:netrw_dirhist_cnt") || !exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") || g:netrw_dirhist_{g:netrw_dirhist_cnt} != a:curdir
let g:netrw_dirhist_cnt = ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
let g:netrw_dirhist_{g:netrw_dirhist_cnt} = a:curdir
" call Decho("save dirhist#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
endif
elseif a:chg == 4
" u: change to the previous directory stored on the history list
" call Decho("(user: <u>) chg to prev dir from history")
let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
if g:NETRW_DIRHIST_CNT < 0
let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax
if g:netrw_dirhist_cnt < 0
let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax
endif
if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}")
" call Decho("changedir u#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")
" call Decho("changedir u#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
setlocal ma noro
" call Decho("setlocal ma noro")
@ -1988,19 +2013,19 @@ fun! s:NetrwBookmarkDir(chg,curdir)
setlocal nomod
" call Decho("setlocal nomod")
endif
" " call Decho("exe e! ".fnameescape(g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}))
exe "e! ".fnameescape(g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT})
" " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))
exe "e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})
else
let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
echo "Sorry, no predecessor directory exists yet"
endif
elseif a:chg == 5
" U: change to the subsequent directory stored on the history list
" call Decho("(user: <U>) chg to next dir from history")
let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}")
" call Decho("changedir U#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")
" call Decho("changedir U#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
setlocal ma noro
" call Decho("setlocal ma noro")
@ -2009,57 +2034,103 @@ fun! s:NetrwBookmarkDir(chg,curdir)
setlocal nomod
" call Decho("setlocal nomod")
endif
" call Decho("exe e! ".fnameescape(g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}))
exe "e! ".fnameescape(g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT})
" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))
exe "e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})
else
let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
if g:NETRW_DIRHIST_CNT < 0
let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax
if g:netrw_dirhist_cnt < 0
let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax
endif
echo "Sorry, no successor directory exists yet"
endif
elseif a:chg == 6
if v:count > 0 && v:count == g:NETRW_BOOKMARKMAX
" delete the v:count'th bookmark
" call Decho("delete bookmark#".v:count."<".g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX}.">")
unlet g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX}
let g:NETRW_BOOKMARKMAX= g:NETRW_BOOKMARKMAX - 1
elseif v:count > 0
" call Decho("delete by shifting bookmark#".v:count."<".g:NETRW_BOOKMARKDIR_{v:count}.">")
let cnt= v:count
while cnt < g:NETRW_BOOKMARKMAX
let g:NETRW_BOOKMARKDIR_{cnt} = g:NETRW_BOOKMARKDIR_{(cnt+1)}
let cnt = cnt + 1
endwhile
unlet g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX}
let g:NETRW_BOOKMARKMAX= g:NETRW_BOOKMARKMAX - 1
elseif exists("b:netrw_curdir")
" look for current directory amongst the bookmarks and remove that bookmark
" call Decho("search for bookmark<".b:netrw_curdir.">")
let cnt= 1
while cnt <= g:NETRW_BOOKMARKMAX
" call Decho("checking: g:NETRW_BOOKMARKDIR_".cnt."<".g:NETRW_BOOKMARKDIR_{cnt}.">")
if g:NETRW_BOOKMARKDIR_{cnt} == b:netrw_curdir
if cnt < g:NETRW_BOOKMARKMAX
" call Decho("delete bookmark#".cnt."<".b:netrw_curdir.">")
while cnt < g:NETRW_BOOKMARMAX
let g:NETRW_BOOKMARKDIR_{cnt} = g:NETRW_BOOKMARKDIR_{(cnt+1)}
let cnt = cnt + 1
endwhile
endif
unlet g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX}
let g:NETRW_BOOKMARKMAX= g:NETRW_BOOKMARKMAX - 1
endif
let cnt= cnt + 1
endwhile
" delete the v:count'th bookmark
" call Decho("delete bookmark#".v:count."<".g:netrw_bookmarklist[v:count-1].">")
let savefile= s:NetrwHome()."/.netrwbook"
if filereadable(savefile)
call s:NetrwBookHistSave() " done here to merge bookmarks first
call delete(savefile)
endif
call remove(g:netrw_bookmarklist,v:count-1)
endif
call s:NetrwBookmarkMenu()
" call Dret("NetrwBookmarkDir")
" call Dret("NetrwBookHistHandler")
endfun
" ---------------------------------------------------------------------
" s:NetrwBookHistRead: this function reads bookmarks and history {{{2
" Sister function: s:NetrwBookHistSave()
fun! s:NetrwBookHistRead()
" call Dfunc("s:NetrwBookHistRead()")
if !exists("s:netrw_initbookhist")
let savefile= s:NetrwHome()."/.netrwbook"
if filereadable(savefile)
" call Decho("sourcing .netrwbook")
exe "so ".savefile
endif
let savefile= s:NetrwHome()."/.netrwhist"
if filereadable(savefile)
" call Decho("sourcing .netrwhist")
exe "so ".savefile
endif
let s:netrw_initbookhist= 1
au VimLeave * call s:NetrwBookHistSave()
endif
" call Dret("s:NetrwBookHistRead")
endfun
" ---------------------------------------------------------------------
" s:NetrwBookHistSave: this function saves bookmarks and history {{{2
" Sister function: s:NetrwBookHistRead()
" I used to do this via viminfo but that appears to
" be unreliable for long-term storage
" COMBAK: does $HOME work under windows???
fun! s:NetrwBookHistSave()
" call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax)
let savefile= s:NetrwHome()."/.netrwhist"
1split
enew
setlocal noswf
" save .netrwhist -- no attempt to merge
file .netrwhist
call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax)
call setline(2,"let g:netrw_dirhist_cnt =".g:netrw_dirhist_cnt)
let lastline = line("$")
let cnt = 1
while cnt <= g:netrw_dirhist_cnt
call setline((cnt+lastline),'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'")
let cnt= cnt + 1
endwhile
exe "silent! w! ".savefile
%d
if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != []
" merge and write .netrwbook
let savefile= s:NetrwHome()."/.netrwbook"
if filereadable(savefile)
let booklist= deepcopy(g:netrw_bookmarklist)
exe "silent so ".savefile
for bdm in booklist
if index(g:netrw_bookmarklist,bdm) == -1
call add(g:netrw_bookmarklist,bdm)
endif
endfor
call sort(g:netrw_bookmarklist)
exe "silent! w! ".savefile
endif
" construct and save .netrwbook
call setline(1,"let g:netrw_bookmarklist= ".string(g:netrw_bookmarklist))
exe "silent! w! ".savefile
endif
let bgone= bufnr("%")
q!
exe bgone."bwipe!"
" call Dret("s:NetrwBookHistSave")
endfun
" ---------------------------------------------------------------------
@ -2072,6 +2143,9 @@ fun! s:NetrwBrowse(islocal,dirname)
" call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%").">")
" call Decho("tab#".tabpagenr()." win#".winnr())
" call Dredir("ls!")
if !exists("s:netrw_initbookhist")
call s:NetrwBookHistRead()
endif
if exists("s:netrw_skipbrowse")
unlet s:netrw_skipbrowse
@ -2269,6 +2343,14 @@ fun! s:NetrwBrowse(islocal,dirname)
call s:BrowserMaps(a:islocal)
call s:PerformListing(a:islocal)
" The s:LocalBrowseShellCmdRefresh() function is called by an autocmd
" installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow, medium speed).
" However, s:NetrwBrowse() causes the ShellCmdPost event itself to fire once; setting
" the variable below avoids that second refresh of the screen. The s:LocalBrowseShellCmdRefresh()
" function gets called due to that autocmd; it notices that the following variable is set
" and skips the refresh and sets s:locbrowseshellcmd to zero. Oct 13, 2008
let s:locbrowseshellcmd= 1
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
" call Dret("s:NetrwBrowse : did PerformListing")
return
@ -2328,7 +2410,7 @@ fun! s:NetrwGetBuffer(islocal,dirname)
set ei=all
exe "b ".w:netrw_treebufnr
let &ei= eikeep
" call Dret("s:NetrwGetBuffer : bufnum#".bufnum."<NetrwTreeListing>")
" call Dret("s:NetrwGetBuffer : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>")
return
endif
let bufnum= -1
@ -2706,37 +2788,47 @@ fun! s:NetrwBookmarkMenu()
if !exists("s:netrw_menucnt")
return
endif
" call Dfunc("NetrwBookmarkMenu() bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." menucnt=".s:netrw_menucnt)
" call Dfunc("NetrwBookmarkMenu() histcnt=".g:netrw_dirhist_cnt." menucnt=".s:netrw_menucnt)
" the following test assures that gvim is running, has menus available, and has menus enabled.
if has("gui") && has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu
if exists("g:NetrwTopLvlMenu")
" call Decho("removing ".g:NetrwTopLvlMenu."Bookmarks menu item(s)")
exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmarks'
exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete'
endif
if !exists("s:netrw_initbookhist")
call s:NetrwBookHistRead()
endif
" show bookmarked places
let cnt = 1
while cnt <= g:NETRW_BOOKMARKMAX
if exists("g:NETRW_BOOKMARKDIR_{cnt}")
let bmdir= escape(g:NETRW_BOOKMARKDIR_{cnt},'. ')
" call Decho('silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmdir.' :e '.bmdir)
exe 'silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmdir.' :e '.bmdir."\<cr>"
endif
let cnt= cnt + 1
endwhile
if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != []
let cnt= 1
for bmd in g:netrw_bookmarklist
" call Decho('silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmd.' :e '.bmd)
let bmd= escape(bmd,'. ')
" show bookmarks for goto menu
exe 'silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmd.' :e '.bmd."\<cr>"
" show bookmarks for deletion menu
exe 'silent! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.bmd.' '.cnt."mB"
let cnt= cnt + 1
endfor
endif
" show directory browsing history
let cnt = g:NETRW_DIRHIST_CNT
let cnt = g:netrw_dirhist_cnt
let first = 1
let histcnt = 0
while ( first || cnt != g:NETRW_DIRHIST_CNT )
while ( first || cnt != g:netrw_dirhist_cnt )
let histcnt = histcnt + 1
let priority = g:NETRW_DIRHIST_CNT + histcnt
if exists("g:NETRW_DIRHIST_{cnt}")
let bmdir= escape(g:NETRW_DIRHIST_{cnt},'/&? ')
" call Decho('silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.bmdir)
exe 'silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.bmdir."\<cr>"
let priority = g:netrw_dirhist_cnt + histcnt
if exists("g:netrw_dirhist_{cnt}")
let histdir= escape(g:netrw_dirhist_{cnt},'./&? ')
" call Decho('silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir)
exe 'silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir."\<cr>"
endif
let first = 0
let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
@ -2744,6 +2836,7 @@ fun! s:NetrwBookmarkMenu()
let cnt= cnt + g:netrw_dirhistmax
endif
endwhile
endif
" call Dret("NetrwBookmarkMenu")
endfun
@ -2991,6 +3084,7 @@ fun! netrw#NetrwBrowseX(fname,remote)
if has("win32") || has("win95") || has("win64") || has("win16")
let exten= substitute(exten,'^.*$','\L&\E','')
endif
" call Decho("exten<".exten.">")
" seems kde systems often have gnome-open due to dependencies, even though
" gnome-open's subsidiary display tools are largely absent. Kde systems
@ -3009,16 +3103,25 @@ fun! netrw#NetrwBrowseX(fname,remote)
if a:remote == 1
" create a local copy
let fname= fnamemodify(tempname(),":r").".".exten
" call Decho("a:remote=".a:remote.": create a local copy of <".fname."> as <".fname.">")
exe "silent keepjumps bot 1new ".fnameescape(fname)
" call Decho("a:remote=".a:remote.": create a local copy of <".a:fname.">")
setlocal bh=delete
" call Decho("read <".fnameescape(fname).">, now writing: exe w! ".fnameescape(fname))
exe "silent! w! ".fnameescape(fname)
q
call netrw#NetRead(3,a:fname)
" attempt to rename tempfile
let basename= substitute(a:fname,'^\(.*\)/\(.*\)\.\([^.]*\)$','\2','')
let newname= substitute(s:netrw_tmpfile,'^\(.*\)/\(.*\)\.\([^.]*\)$','\1/'.basename.'.\3','')
" call Decho("basename<".basename.">")
" call Decho("newname <".newname.">")
if rename(s:netrw_tmpfile,newname) == 0
" renaming succeeded
let fname= newname
else
" renaming failed
let fname= s:netrw_tmpfile
endif
else
let fname= a:fname
endif
" call Decho("fname<".fname.">")
" call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten))
" set up redirection
@ -3125,10 +3228,22 @@ endfun
" ---------------------------------------------------------------------
" netrw#Explore: launch the local browser in the directory of the current file {{{2
" dosplit==0: the window will be split iff the current file has
" been modified
" dosplit==1: the window will be split before running the local
" browser
" indx: == -1: Nexplore
" == -2: Pexplore
" == +: this is overloaded:
" * If Nexplore/Pexplore is in use, then this refers to the
" indx'th item in the w:netrw_explore_list[] of items which
" matched the */pattern **/pattern *//pattern **//pattern
" * If Hexplore or Vexplore, then this will override
" g:netrw_winsize to specify the qty of rows or columns the
" newly split window should have.
" dosplit==0: the window will be split iff the current file has been modified
" dosplit==1: the window will be split before running the local browser
" style == 0: Explore style == 1: Explore!
" == 2: Hexplore style == 3: Hexplore!
" == 4: Vexplore style == 5: Vexplore!
" == 6: Texplore
"DechoTabOn
fun! netrw#Explore(indx,dosplit,style,...)
" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." a:0=".a:0)
if !exists("b:netrw_curdir")
@ -3147,30 +3262,34 @@ fun! netrw#Explore(indx,dosplit,style,...)
if a:dosplit || &modified || a:style == 6
" call Decho("case: dosplit=".a:dosplit." modified=".&modified." a:style=".a:style)
call s:SaveWinVars()
let winsize= g:netrw_winsize
if a:indx > 0
let winsize= a:indx
endif
if a:style == 0 " Explore, Sexplore
" call Decho("style=0: Explore or Sexplore")
exe g:netrw_winsize."wincmd s"
exe winsize."wincmd s"
elseif a:style == 1 "Explore!, Sexplore!
" call Decho("style=1: Explore! or Sexplore!")
exe g:netrw_winsize."wincmd v"
exe winsize."wincmd v"
elseif a:style == 2 " Hexplore
" call Decho("style=2: Hexplore")
exe "bel ".g:netrw_winsize."wincmd s"
exe "bel ".winsize."wincmd s"
elseif a:style == 3 " Hexplore!
" call Decho("style=3: Hexplore!")
exe "abo ".g:netrw_winsize."wincmd s"
exe "abo ".winsize."wincmd s"
elseif a:style == 4 " Vexplore
" call Decho("style=4: Vexplore")
exe "lefta ".g:netrw_winsize."wincmd v"
exe "lefta ".winsize."wincmd v"
elseif a:style == 5 " Vexplore!
" call Decho("style=5: Vexplore!")
exe "rightb ".g:netrw_winsize."wincmd v"
exe "rightb ".winsize."wincmd v"
elseif a:style == 6 " Texplore
call s:SaveBufVars()
@ -3301,9 +3420,10 @@ fun! netrw#Explore(indx,dosplit,style,...)
if !exists("w:netrw_explore_indx")
let w:netrw_explore_indx= 0
endif
let indx = a:indx
" call Decho("starpat=".starpat.": set indx= [a:indx=".indx."]")
"
if indx == -1
" Nexplore
" call Decho("case Nexplore with starpat=".starpat.": (indx=".indx.")")
@ -3364,6 +3484,7 @@ fun! netrw#Explore(indx,dosplit,style,...)
if starpat == 1
" starpat=1: Explore *//pattern (current directory only search for files containing pattern)
" call Decho("starpat=".starpat.": build *//pattern list")
" call Decho("pattern<".pattern.">")
exe "vimgrep /".pattern."/gj ".fnameescape(b:netrw_curdir)."/*"
let w:netrw_explore_list = map(getqflist(),'bufname(v:val.bufnr)')
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
@ -3389,14 +3510,12 @@ fun! netrw#Explore(indx,dosplit,style,...)
elseif starpat == 3
" starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
" call Decho("starpat=".starpat.": build */filepat list")
let dirname = substitute(dirname,'^\*/','','')
if dirname !~ '\$*?[' && (!filereadable(dirname) || !filewritable(dirname))
" call Dret("netrw#Explore : no files matched pattern")
call netrw#ErrorMsg(s:NOTE,"no files matched Explore pattern",72)
return
endif
let w:netrw_explore_list= split(expand(b:netrw_curdir."/".dirname),'\n')
if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif
let filepat= substitute(dirname,'^\*/','','')
let filepat= substitute(filepat,'^[%#<]','\\&','')
" call Decho("b:netrw_curdir<".b:netrw_curdir.">")
" call Decho("filepat<".filepat.">")
let w:netrw_explore_list= split(expand(b:netrw_curdir."/".filepat),'\n')
if &hls | let keepregslash= s:ExplorePatHls(filepat) | endif
elseif starpat == 4
" starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
@ -3491,17 +3610,18 @@ fun! netrw#Explore(indx,dosplit,style,...)
let prvfname= ""
for fname in w:netrw_explore_list
" call Decho("fname<".fname.">")
"COMBAK -- g:netrw_markfileesc."'".g:netrw_markfileesc."'" ???
if fname =~ '^'.b:netrw_curdir
if s:explore_match == ""
let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>'
let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>'
else
let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>'
let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>'
endif
elseif fname !~ '^/' && fname != prvfname
if s:explore_match == ""
let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>'
let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc).'\>'
else
let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>'
let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc).'\>'
endif
endif
let prvfname= fname
@ -3600,6 +3720,48 @@ fun! s:NetrwHidden(islocal)
" call Dret("s:NetrwHidden")
endfun
" ---------------------------------------------------------------------
" s:NetrwHome: this function determines a "home" for saving bookmarks and history {{{2
fun! s:NetrwHome()
" call Dfunc("s:NetrwHome()")
if exists("g:netrw_home")
let home= g:netrw_home
else
" go to vim plugin home
for home in split(&rtp,',') + ['']
if isdirectory(home) && filewritable(home) | break | endif
let basehome= substitute(home,'[/\\]\.vim$','','')
if isdirectory(basehome) && filewritable(basehome)
let home= basehome."/.vim"
break
endif
endfor
if home == ""
" just pick the first directory
" call Decho("just pick first directory in &rtp")
let home= substitute(&rtp,',.*$','','')
endif
if (has("win32") || has("win95") || has("win64") || has("win16"))
let home= substitute(home,'/','\\','g')
endif
endif
" insure that the home directory exists
" call Decho("picked home<".home.">")
if !isdirectory(home)
if exists("g:netrw_mkdir")
" call Decho("home<".home."> isn't a directory -- making it now with g:netrw_mkdir<".g:netrw_mkdir.">")
" call Decho("system(".g:netrw_mkdir." ".s:Escape(home).")")
call system(g:netrw_mkdir." ".s:Escape(home))
else
" call Decho("home<".home."> isn't a directory -- making it now with mkdir()")
call mkdir(home)
endif
endif
let g:netrw_home= home
" call Dret("s:NetrwHome <".home.">")
return home
endfun
" ---------------------------------------------------------------------
" s:NetrwLeftmouse: handles the <leftmouse> when in a netrw browsing window {{{2
fun! s:NetrwLeftmouse(islocal)
@ -4048,7 +4210,9 @@ fun! s:NetrwMarkFileCopy(islocal)
if a:islocal
call s:NetrwRefreshDir(a:islocal,b:netrw_curdir)
endif
call s:LocalBrowseShellCmdRefresh()
if g:netrw_fastbrowse <= 1
call s:LocalBrowseShellCmdRefresh()
endif
" call Dret("s:NetrwMarkFileCopy 1")
return 1
@ -4356,7 +4520,9 @@ fun! s:NetrwMarkFileMove(islocal)
if a:islocal
call s:NetrwRefreshDir(a:islocal,b:netrw_curdir)
endif
call s:LocalBrowseShellCmdRefresh()
if g:netrw_fastbrowse <= 1
call s:LocalBrowseShellCmdRefresh()
endif
" call Dret("s:NetrwMarkFileMove")
endfun
@ -4584,7 +4750,7 @@ fun! s:NetrwMarkFileTgt(islocal)
endif
let s:netrwmftgt_islocal= a:islocal
if g:netrw_fastbrowse > 0
if g:netrw_fastbrowse <= 1
call s:LocalBrowseShellCmdRefresh()
endif
call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
@ -4719,20 +4885,17 @@ fun! s:NetrwMenu(domenu)
" call Decho("initialize menu")
let s:netrw_menu_enabled= 1
exe 'silent! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>'
call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4
exe 'silent! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :'
exe 'silent! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -'
exe 'silent! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x'
exe 'silent! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directory<tab>mb mb'
exe 'silent! menu '.g:NetrwMenuPriority.'.8.2 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete<tab>mB mB'
exe 'silent! menu '.g:NetrwMenuPriority.'.8.3 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Bookmark<tab>gb gb'
exe 'silent! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)<tab>u u'
exe 'silent! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)<tab>U U'
exe 'silent! menu '.g:NetrwMenuPriority.'.8.6 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.List<tab>qb qb'
exe 'silent! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List<tab>'."<ctrl-h> \<Plug>NetrwHideEdit"
exe 'silent! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List<tab><ctrl-h>'." \<c-h>'"
exe 'silent! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ Sequence<tab>S S'
exe 'silent! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files<tab>'."gh gh"
exe 'silent! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing<tab>'."<ctrl-l> \<Plug>NetrwRefresh"
exe 'silent! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing<tab>'."<ctrl-l> \<c-l>"
exe 'silent! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>"
exe 'silent! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D'
exe 'silent! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window<tab><cr> '."\<cr>"
@ -4770,6 +4933,7 @@ fun! s:NetrwMenu(domenu)
exe 'silent! menu '.g:NetrwMenuPriority.'.16.4 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method\ (name-time-size)<tab>s s'
exe 'silent! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R'
exe 'silent! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c'
call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4, 8.2.x
let s:netrw_menucnt= 28
elseif !a:domenu
@ -5482,12 +5646,12 @@ fun! s:NetrwSplit(mode)
elseif a:mode == 1
" remote and t
let cursorword = s:NetrwGetWord()
let newdir = s:NetrwBrowseChgDir(0,s:NetrwGetWord())
" call Decho("tabnew")
tabnew
let s:didsplit= 1
call s:RestoreWinVars()
call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,cursorword))
call s:NetrwBrowse(0,newdir)
unlet s:didsplit
elseif a:mode == 2
@ -5810,7 +5974,7 @@ fun! s:PerformListing(islocal)
endif
" save current directory on directory history list
call s:NetrwBookmarkDir(3,b:netrw_curdir)
call s:NetrwBookHistHandler(3,b:netrw_curdir)
" Set up the banner {{{3
" call Decho("set up banner")
@ -6739,6 +6903,14 @@ fun! s:LocalBrowseShellCmdRefresh()
" call Dret("LocalBrowseShellCmdRefresh : don't refresh when focus not on netrw windwo")
return
endif
if exists("s:locbrowseshellcmd")
if s:locbrowseshellcmd
let s:locbrowseshellcmd= 0
" call Dret("LocalBrowseShellCmdRefresh : NetrwBrowse itself caused the refresh")
return
endif
let s:locbrowseshellcmd= 0
endif
let itab = 1
let buftablist = []
while itab <= tabpagenr("$")
@ -7030,9 +7202,11 @@ fun! s:LocalFastBrowser()
augroup AuNetrwShellCmd
au!
if (has("win32") || has("win95") || has("win64") || has("win16"))
" call Decho("autocmd: ShellCmdPost * call s:LocalBrowseShellCmdRefresh()")
au ShellCmdPost * call s:LocalBrowseShellCmdRefresh()
else
au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()
" call Decho("autocmd: ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()")
endif
augroup END
endif
@ -7059,7 +7233,7 @@ endfun
" 0=note = s:NOTE
" 1=warning = s:WARNING
" 2=error = s:ERROR
" Aug 22, 2008 : max errnum currently is 72
" Oct 12, 2008 : max errnum currently is 73
fun! netrw#ErrorMsg(level,msg,errnum)
" call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow)
@ -7287,7 +7461,7 @@ fun! s:GetTempfile(fname)
endif
" let netrw#NetSource() know about the tmpfile
let s:netrw_tmpfile= tmpfile " used by netrw#NetSource()
let s:netrw_tmpfile= tmpfile " used by netrw#NetSource() and netrw#NetrwBrowseX()
" call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">")
" o/s dependencies
@ -7659,8 +7833,7 @@ fun! s:SetRexDir(islocal,dirname)
if a:islocal
exe 'com! Rexplore call s:NetrwRexplore(1,"'.escape(a:dirname,'"\').'")'
if g:netrw_retmap
silent! unmap <2-leftmouse>
if !hasmapto("<Plug>NetrwReturn")
if !hasmapto("<Plug>NetrwReturn") && maparg("<2-leftmouse>","n") == ""
nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn
endif
let dir = escape(a:dirname, s:netrw_map_escape)
@ -7669,8 +7842,7 @@ fun! s:SetRexDir(islocal,dirname)
else
exe 'com! Rexplore call s:NetrwRexplore(0,"'.escape(a:dirname,'"\').'")'
if g:netrw_retmap
silent! unmap <2-leftmouse>
if !hasmapto("<Plug>NetrwReturn")
if !hasmapto("<Plug>NetrwReturn") && maparg("<2-leftmouse>","n") == ""
nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn
endif
let dir = escape(a:dirname, s:netrw_map_escape)

View File

@ -1,9 +1,9 @@
" netrwFileHandlers: contains various extension-based file handlers for
" netrw's browsers' x command ("eXecute launcher")
" Author: Charles E. Campbell, Jr.
" Date: May 30, 2006
" Version: 9
" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
" Date: Sep 30, 2008
" Version: 10
" Copyright: Copyright (C) 1999-2008 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,
@ -20,9 +20,15 @@
if exists("g:loaded_netrwFileHandlers") || &cp
finish
endif
let g:loaded_netrwFileHandlers= "v10"
if v:version < 702
echohl WarningMsg
echo "***warning*** this version of netrwFileHandlers needs vim 7.2"
echohl Normal
finish
endif
let s:keepcpo= &cpo
set cpo&vim
let g:loaded_netrwFileHandlers= "v9"
" ---------------------------------------------------------------------
" netrwFileHandlers#Invoke: {{{1
@ -73,10 +79,10 @@ fun! s:NFH_html(pagefile)
if executable("mozilla")
" call Decho("executing !mozilla ".page)
exe "!mozilla ".g:netrw_shq.page.g:netrw_shq
exe "!mozilla ".shellescape(page,1)
elseif executable("netscape")
" call Decho("executing !netscape ".page)
exe "!netscape ".g:netrw_shq..page.g:netrw_shq
exe "!netscape ".shellescape(page,1)
else
" call Dret("s:NFH_html 0")
return 0
@ -96,10 +102,10 @@ fun! s:NFH_htm(pagefile)
if executable("mozilla")
" call Decho("executing !mozilla ".page)
exe "!mozilla ".g:netrw_shq.page.g:netrw_shq
exe "!mozilla ".shellescape(page,1)
elseif executable("netscape")
" call Decho("executing !netscape ".page)
exe "!netscape ".g:netrw_shq.page.g:netrw_shq
exe "!netscape ".shellescape(page,1)
else
" call Dret("s:NFH_htm 0")
return 0
@ -115,10 +121,10 @@ fun! s:NFH_jpg(jpgfile)
" call Dfunc("s:NFH_jpg(jpgfile<".a:jpgfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".g:netrw_shq.a:jpgfile.g:netrw_shq
exe "silent! !gimp -s ".shellescape(a:jpgfile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
" call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'"))
exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".g:netrw_shq.a:jpgfile.g:netrw_shq
exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:jpgfile,1)
else
" call Dret("s:NFH_jpg 0")
return 0
@ -134,9 +140,9 @@ fun! s:NFH_gif(giffile)
" call Dfunc("s:NFH_gif(giffile<".a:giffile.">)")
if executable("gimp")
exe "silent! !gimp -s ".g:netrw_shq.a:giffile.g:netrw_shq
exe "silent! !gimp -s ".shellescape(a:giffile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".g:netrw_shq.a:giffile.g:netrw_shq
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:giffile,1)
else
" call Dret("s:NFH_gif 0")
return 0
@ -152,9 +158,9 @@ fun! s:NFH_png(pngfile)
" call Dfunc("s:NFH_png(pngfile<".a:pngfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".g:netrw_shq.a:pngfile.g:netrw_shq
exe "silent! !gimp -s ".shellescape(a:pngfile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".g:netrw_shq.a:pngfile.g:netrw_shq
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pngfile,1)
else
" call Dret("s:NFH_png 0")
return 0
@ -170,9 +176,9 @@ fun! s:NFH_pnm(pnmfile)
" call Dfunc("s:NFH_pnm(pnmfile<".a:pnmfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".g:netrw_shq.a:pnmfile.g:netrw_shq
exe "silent! !gimp -s ".shellescape(a:pnmfile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".g:netrw_shq.a:pnmfile.g:netrw_shq
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pnmfile,1)
else
" call Dret("s:NFH_pnm 0")
return 0
@ -190,7 +196,7 @@ fun! s:NFH_bmp(bmpfile)
if executable("gimp")
exe "silent! !gimp -s ".a:bmpfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".g:netrw_shq.a:bmpfile.g:netrw_shq
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:bmpfile,1)
else
" call Dret("s:NFH_bmp 0")
return 0
@ -205,9 +211,9 @@ endfun
fun! s:NFH_pdf(pdf)
" call Dfunc("s:NFH_pdf(pdf<".a:pdf.">)")
if executable("gs")
exe 'silent! !gs '.g:netrw_shq.a:pdf.g:netrw_shq
exe 'silent! !gs '.shellescape(a:pdf,1)
elseif executable("pdftotext")
exe 'silent! pdftotext -nopgbrk '.g:netrw_shq.a:pdf.g:netrw_shq
exe 'silent! pdftotext -nopgbrk '.shellescape(a:pdf,1)
else
" call Dret("s:NFH_pdf 0")
return 0
@ -223,7 +229,7 @@ fun! s:NFH_doc(doc)
" call Dfunc("s:NFH_doc(doc<".a:doc.">)")
if executable("oowriter")
exe 'silent! !oowriter '.g:netrw_shq.a:doc.g:netrw_shq
exe 'silent! !oowriter '.shellescape(a:doc,1)
redraw!
else
" call Dret("s:NFH_doc 0")
@ -240,7 +246,7 @@ fun! s:NFH_sxw(sxw)
" call Dfunc("s:NFH_sxw(sxw<".a:sxw.">)")
if executable("oowriter")
exe 'silent! !oowriter '.g:netrw_shq.a:sxw.g:netrw_shq
exe 'silent! !oowriter '.shellescape(a:sxw,1)
redraw!
else
" call Dret("s:NFH_sxw 0")
@ -257,7 +263,7 @@ fun! s:NFH_xls(xls)
" call Dfunc("s:NFH_xls(xls<".a:xls.">)")
if executable("oocalc")
exe 'silent! !oocalc '.g:netrw_shq.a:xls.g:netrw_shq
exe 'silent! !oocalc '.shellescape(a:xls,1)
redraw!
else
" call Dret("s:NFH_xls 0")
@ -274,15 +280,15 @@ fun! s:NFH_ps(ps)
" call Dfunc("s:NFH_ps(ps<".a:ps.">)")
if executable("gs")
" call Decho("exe silent! !gs ".a:ps)
exe "silent! !gs ".g:netrw_shq.a:ps.g:netrw_shq
exe "silent! !gs ".shellescape(a:ps,1)
redraw!
elseif executable("ghostscript")
" call Decho("exe silent! !ghostscript ".a:ps)
exe "silent! !ghostscript ".g:netrw_shq.a:ps.g:netrw_shq
exe "silent! !ghostscript ".shellescape(a:ps,1)
redraw!
elseif executable("gswin32")
" call Decho("exe silent! !gswin32 ".g:netrw_shq.a:ps.g:netrw_shq)
exe "silent! !gswin32 ".g:netrw_shq.a:ps.g:netrw_shq
" call Decho("exe silent! !gswin32 ".shellescape(a:ps,1))
exe "silent! !gswin32 ".shellescape(a:ps,1)
redraw!
else
" call Dret("s:NFH_ps 0")
@ -298,16 +304,16 @@ endfun
fun! s:NFH_eps(eps)
" call Dfunc("s:NFH_eps()")
if executable("gs")
exe "silent! !gs ".g:netrw_shq.a:eps.g:netrw_shq
exe "silent! !gs ".shellescape(a:eps,1)
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".g:netrw_shq.a:eps.g:netrw_shq
exe "silent! !ghostscript ".shellescape(a:eps,1)
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".g:netrw_shq.a:eps.g:netrw_shq
exe "silent! !ghostscript ".shellescape(a:eps,1)
redraw!
elseif executable("gswin32")
exe "silent! !gswin32 ".g:netrw_shq.a:eps.g:netrw_shq
exe "silent! !gswin32 ".shellescape(a:eps,1)
redraw!
else
" call Dret("s:NFH_eps 0")

View File

@ -19,7 +19,13 @@
if exists("g:loaded_netrwSettings") || &cp
finish
endif
let g:loaded_netrwSettings = "v13"
let g:loaded_netrwSettings = "v13"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of netrwSettings needs vim 7.0"
echohl Normal
finish
endif
" ---------------------------------------------------------------------
" NetrwSettings: {{{1

View File

@ -1,14 +1,14 @@
*align.txt* The Alignment Tool Mar 06, 2008
*align.txt* The Alignment Tool Oct 29, 2008
Author: Charles E. Campbell, Jr. <NdrOchip@ScampbellPfamily.AbizM>
(remove NOSPAM from Campbell's email first)
Author: Charles E. Campbell, Jr. <NdrOchip@ScampbellPfamily.AbizM>
(remove NOSPAM from Campbell's email first)
Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
The VIM LICENSE applies to Align.vim, AlignMaps.vim, and Align.txt
(see |copyright|) except use "Align and AlignMaps" instead of "Vim"
NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK.
NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK.
==============================================================================
1. Contents *align* *align-contents*
1. Contents *align* *align-contents* {{{1
1. Contents.................: |align-contents|
2. Alignment Manual.........: |align-manual|
@ -27,7 +27,7 @@ Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
Padding................: |alignctrl-p| |alignctrl-P|
Current Options........: |alignctrl-settings| |alignctrl-|
Alignment................: |align-align|
Maps.....................: |align-maps|
4. Alignment Maps...........: |align-maps|
\a,....................: |alignmap-a,|
\a?....................: |alignmap-a?|
\a<....................: |alignmap-a<|
@ -46,10 +46,10 @@ Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
\t=....................: |alignmap-t=|
\T=....................: |alignmap-T=|
\Htd...................: |alignmap-Htd|
4. Alignment Tool History...: |align-history|
5. Alignment Tool History...: |align-history|
==============================================================================
2. Align Manual *alignman* *alignmanual* *align-manual*
2. Align Manual *alignman* *alignmanual* *align-manual* {{{1
To Enable: put <Align.vim> and <AlignMaps.vim> into your .vim/plugin
To see a user's guide, see |align-usage|
@ -130,10 +130,10 @@ Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
\=============================================================================/
==============================================================================
3. Alignment Usage *alignusage* *align-usage*
3. Alignment Usage *alignusage* *align-usage* {{{1
ALIGNMENT CONCEPTS *align-concept* *align-concepts*
ALIGNMENT CONCEPTS *align-concept* *align-concepts* {{{2
The typical text to be aligned is considered to be:
@ -197,7 +197,7 @@ ALIGNMENT CONCEPTS *align-concept* *align-concepts*
there will help, too.
ALIGNMENT COMMANDS *align-command* *align-commands*
ALIGNMENT COMMANDS *align-command* *align-commands* {{{2
The <Align.vim> script includes two primary commands and two
minor commands:
@ -226,10 +226,13 @@ ALIGNMENT COMMANDS *align-command* *align-commands*
ex. :%Align! p2P2 =
< This will align all "=" in the file with two padding
spaces on both sides of each "=" sign.
NOTE ON PATTERNS:~
Align and AlignCtrl use |<f-args>| to obtain their
input patterns; hence, to get a \ you'll need to enter
two backslashes: \\.
NOTE ON USING PATTERNS WITH ALIGN:~
Align and AlignCtrl use |<q-args>| to obtain their
input patterns and they use an internal function to
split arguments at whitespace unless inside "..."s.
One may escape characters inside a double-quote string
by preceding such characters with a backslash.
AlignPush : this command/function pushes the current AlignCtrl
state onto an internal stack. >
@ -248,10 +251,10 @@ ALIGNMENT COMMANDS *align-command* *align-commands*
was last used.
<
ALIGNMENT OPTIONS *align-option* *align-options*
ALIGNMENT OPTIONS *align-option* *align-options* {{{2
*align-utf8* *align-utf* *align-codepoint* *align-strlen* *align-multibyte*
*align-utf8* *align-utf* *align-codepoint* *align-strlen*
For those of you who are using 2-byte (or more) characters such as is
For those of you who are using 2-byte (or more) characters such as are
available with utf-8, Align now provides a special option which you
may choose based upon your needs:
@ -269,18 +272,18 @@ ALIGNMENT OPTIONS *align-option* *align-options*
'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when~
immediately preceded by lam, one otherwise, etc.)~
>
let g:Align_xstrlen= 2
let g:Align_xstrlen= 3
<
By putting one of these settings into your <.vimrc>, Align will use an
internal (interpreted) function to determine a string's length instead
of the built-in to Vim's |strlen()| function. As the function is
of the Vim's built-in |strlen()| function. As the function is
interpreted, Align will run a bit slower but will handle such strings
correctly. The last setting (g:Align_xstrlen= 2) probably will run
the slowest but be the most accurate.
(thanks to Tony Mechelynck for these)
correctly. The last setting (g:Align_xstrlen= 3) probably will run
the slowest but be the most accurate. (thanks to Tony Mechelynck for
these)
ALIGNMENT CONTROL *alignctrl* *align-control*
ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
This command doesn't do the alignment operation itself; instead, it
controls the subsequent alignment operation(s).
@ -294,12 +297,12 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
The typical text line is considered to be composed of two or more
fields separated by one or more separator pattern(s):
>
ws field ws separator ws field ws separator ... < where "ws"
ws field ws separator ws field ws separator ...
<
stands for "white space" such as blanks and/or tabs.
where "ws" stands for "white space" such as blanks and/or tabs.
Separators *alignctrl-separators*
SEPARATORS *alignctrl-separators* {{{3
As a result, separators may not have white space (tabs or blanks) on
their outsides (ie. ": :" is fine as a separator, but " :: " is
@ -311,14 +314,14 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
(ie. @), and then perform a substitute to revert the separators back
to their desired condition (ie. s/@/ :: /g).
The Align() function will first convert tabs over the region into
The Align#Align() function will first convert tabs over the region into
spaces and then apply alignment control. Except for initial white
space, white space surrounding the fields is ignored. One has three
options just for handling initial white space:
--- *alignctrl-w*
wWI INITIAL WHITE SPACE *alignctrl-W*
wWI INITIAL WHITE SPACE *alignctrl-W* {{{3
--- *alignctrl-I*
w : ignore all selected lines' initial white space
W : retain all selected lines' initial white space
@ -344,7 +347,7 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
------ *alignctrl-l*
lrc-+: FIELD JUSTIFICATION *alignctrl-r*
lrc-+: FIELD JUSTIFICATION *alignctrl-r* {{{3
------ *alignctrl-c*
With "lrc", the fields will be left-justified, right-justified, or
@ -379,9 +382,9 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
Even more separator control is available. With "-+:":
- : skip treating the separator as a separator. *alignctrl--*
+ : repeat use of the last "lrc" justification *alignctrl-+*
: : treat the rest of the line as a single field *alignctrl-:*
- : skip treating the separator as a separator. *alignctrl--*
+ : repeat use of the last "lrc" justification *alignctrl-+*
: : treat the rest of the line as a single field *alignctrl-:*
Example: More justification options: Align = >
+------------+---------------+--------------------+---------------+
@ -427,8 +430,8 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
etc.
--- *alignctrl-=*
=C CYCLIC VS ALL-ACTIVE SEPARATORS *alignctrl-C*
--- *alignctrl-=*
=C CYCLIC VS ALL-ACTIVE SEPARATORS *alignctrl-C* {{{3
---
The separators themselves may be considered as equivalent and
@ -525,7 +528,7 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
<
--- *alignctrl-<*
<>| SEPARATOR JUSTIFICATION *alignctrl->*
<>| SEPARATOR JUSTIFICATION *alignctrl->* {{{3
--- *alignctrl-|*
Separators may be of differing lengths as shown in the example below.
@ -553,14 +556,14 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
<
--- *alignctrl-g*
gv SELECTIVE APPLICATION *alignctrl-v*
gv SELECTIVE APPLICATION *alignctrl-v* {{{3
---
These two options provide a way to select (g) or to deselect (v) lines
based on a pattern. Ideally :g/pat/Align would work; unfortunately
it results in Align() being called on each line satisfying the pattern
separately. >
it results in Align#Align() being called on each line satisfying the
pattern separately. >
AlignCtrl g pattern
<
@ -598,20 +601,20 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
<
---
m MAP SUPPORT *alignctrl-m*
m MAP SUPPORT *alignctrl-m* {{{3
---
This option primarily supports the development of maps. The AlignCtrl
call will first do an AlignPush() (ie. retain current alignment
control settings). The next Align() will, in addition to its
alignment job, finish up with an AlignPop(). Thus the AlignCtrl
settings that follow the "m" are only temporarily in effect for just
the next Align().
This option primarily supports the development of maps. The
Align#AlignCtrl() call will first do an Align#AlignPush() (ie. retain
current alignment control settings). The next Align#Align() will, in
addition to its alignment job, finish up with an Align#AlignPop().
Thus the Align#AlignCtrl settings that follow the "m" are only
temporarily in effect for just the next Align#Align().
---
p### *alignctrl-p*
P### PADDING *alignctrl-P*
P### PADDING *alignctrl-P* {{{3
---
These two options control pre-padding and post-padding with blanks
@ -639,7 +642,7 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
etc.
--------------- *alignctrl-settings*
No option given DISPLAY STATUS *alignctrl-*
No option given DISPLAY STATUS *alignctrl-* {{{3
--------------- *alignctrl-no-option*
AlignCtrl, when called with no arguments, will display the current
@ -655,17 +658,18 @@ ALIGNMENT CONTROL *alignctrl* *align-control*
One may get a string which can be fed back into AlignCtrl: >
:let alignctrl= AlignCtrl()
:let alignctrl= Align#AlignCtrl()
<
This form will put a string describing the current AlignCtrl options,
except for the "g" and "v" patterns, into a variable. The AlignCtrl()
function will still echo its settings, however. One can feed any
non-supported "option" to AlignCtrl() to prevent this, however: >
except for the "g" and "v" patterns, into a variable. The
Align#AlignCtrl() function will still echo its settings, however. One
can feed any non-supported "option" to AlignCtrl() to prevent this,
however: >
:let alignctrl= AlignCtrl("d")
:let alignctrl= Align#AlignCtrl("d")
<
ALIGNMENT *align-align*
ALIGNMENT *align-align* {{{2
Once the alignment control has been determined, the user specifies a
range of lines for the Align command/function to do its thing.
@ -721,15 +725,27 @@ ALIGNMENT *align-align*
The whitespace on either side of a separator is ignored.
ALIGNMENT MAPS *alignmaps* *align-maps*
==============================================================================
4. Alignment Maps *alignmaps* *align-maps* {{{1
There are a number of maps using AlignCtrl() and Align() in the
There are a number of maps using Align#AlignCtrl() and Align#Align() in the
<AlignMaps.vim> file. This file may also be put into the plugins
subdirectory. Since AlignCtrl and Align supercede textab and its
<ttalign.vim> file, the maps either have a leading "t" (for "textab")
or the more complicated ones an "a" (for "alignment") for backwards
compatibility.
Thee maps are shown below with a leading backslash (\). Actually,
the <Leader> construct is used (see :help mapleader), so the leading
map kick-off character is easily customized.
Furthermore, all AlignMaps.vim maps use the <Plug> construct (see
|<Plug>|and |<usr_41.txt|). Hence, if one wishes to override the
mapping entirely, one may do that, too. As an example: >
map <Leader>ACOM <Plug>AM_acom
< would have \ACOM do what \acom previously did (assuming that the
mapleader has been left at its default value of a backslash).
\a, : useful for breaking up comma-separated
declarations prior to \adec |alignmap-a,|
\a? : aligns (...)? ...:... expressions on ? and : |alignmap-a?|
@ -805,13 +821,13 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
let g:DrChipTopLvlMenu= "DrChip."
< If you set the variable to the empty string (""), then no menu items
will be produced. Of course, one must have a vim with +menu, the gui
must be running, and *'go'* must have the menu bar suboption (ie. m
must be running, and |'go'| must have the menu bar suboption (ie. m
must be included).
COMPLEX ALIGNMENT MAP METHOD~
For those complex alignment maps which do alignment on constructs
(e.g. \acom, \adec, etc), a series of substitutes is used to insert
"@" symbols in appropriate locations. Align() is then used to do
"@" symbols in appropriate locations. Align#Align() is then used to do
alignment directly on "@"s; then it is followed by further substitutes
to do clean-up. However, the maps \WS and \WE protect any original
embedded "@" symbols by first converting them to <DEL> characters,
@ -819,7 +835,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
---------------------------
Alignment Map Examples: \a, *alignmap-a,*
Alignment Map Examples: \a, *alignmap-a,* {{{3
---------------------------
Original: illustrates comma-separated declaration splitting: >
@ -835,7 +851,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \a? *alignmap-a?*
Alignment Map Examples: \a? *alignmap-a?* {{{3
---------------------------
Original: illustrates ()?: aligning >
@ -852,7 +868,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \a< *alignmap-a<*
Alignment Map Examples: \a< *alignmap-a<* {{{3
---------------------------
Original: illustrating aligning of << and >> >
@ -869,7 +885,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \a= *alignmap-a=*
Alignment Map Examples: \a= *alignmap-a=* {{{3
---------------------------
Original: illustrates how to align := assignments >
@ -884,7 +900,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \abox *alignmap-abox*
Alignment Map Examples: \abox *alignmap-abox* {{{3
---------------------------
Original: illustrates how to comment-box some text >
@ -903,7 +919,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \acom *alignmap-acom*
Alignment Map Examples: \acom *alignmap-acom* {{{3
---------------------------
Original: illustrates aligning C-style comments (works for //, too) >
@ -920,7 +936,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
---------------------------
Alignment Map Examples: \anum *alignmap-anum*
Alignment Map Examples: \anum *alignmap-anum* {{{3
---------------------------
Original: illustrates how to get numbers lined up >
@ -972,7 +988,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
---------------------------
Alignment Map Examples: \ascom *alignmap-ascom*
Alignment Map Examples: \ascom *alignmap-ascom* {{{3
---------------------------
Original: >
@ -987,7 +1003,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \adec *alignmap-adec*
Alignment Map Examples: \adec *alignmap-adec* {{{3
---------------------------
Original: illustrates how to clean up C/C++ declarations >
@ -1032,7 +1048,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \adef *alignmap-adef*
Alignment Map Examples: \adef *alignmap-adef* {{{3
---------------------------
Original: illustrates how to line up #def'initions >
@ -1049,7 +1065,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \afnc *alignmap-afnc*
Alignment Map Examples: \afnc *alignmap-afnc* {{{3
---------------------------
This map is an exception to the usual selection rules.
@ -1079,7 +1095,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \adcom *alignmap-adcom*
Alignment Map Examples: \adcom *alignmap-adcom* {{{3
---------------------------
Original: illustrates aligning comments that don't begin
@ -1102,7 +1118,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \aocom *alignmap-aocom*
Alignment Map Examples: \aocom *alignmap-aocom* {{{3
---------------------------
Original: illustrates how to align C-style comments (works for //, too)
@ -1121,7 +1137,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
---------------------------
Alignment Map Examples: \tsp *alignmap-tsp*
Alignment Map Examples: \tsp *alignmap-tsp* {{{3
---------------------------
Normally Align can't use white spaces for field separators as such
@ -1145,7 +1161,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \tsq *alignmap-tsq*
Alignment Map Examples: \tsq *alignmap-tsq* {{{3
---------------------------
The \tsp map is useful for aligning tables based on white space,
@ -1163,7 +1179,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \tt *alignmap-tt*
Alignment Map Examples: \tt *alignmap-tt* {{{3
---------------------------
Original: illustrates aligning a LaTex Table >
@ -1187,7 +1203,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
----------------------------
Alignment Map Examples: \tml *alignmap-tml*
Alignment Map Examples: \tml *alignmap-tml* {{{3
----------------------------
Original: illustrates aligning multi-line continuation marks >
@ -1208,7 +1224,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \t= *alignmap-t=*
Alignment Map Examples: \t= *alignmap-t=* {{{3
---------------------------
Original: illustrates left-justified aligning of = >
@ -1223,7 +1239,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \T= *alignmap-T=*
Alignment Map Examples: \T= *alignmap-T=* {{{3
---------------------------
Original: illustrates right-justified aligning of = >
@ -1238,7 +1254,7 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
<
---------------------------
Alignment Map Examples: \Htd *alignmap-Htd*
Alignment Map Examples: \Htd *alignmap-Htd* {{{3
---------------------------
Original: for aligning tables with html >
@ -1253,6 +1269,8 @@ ALIGNMENT MAPS *alignmaps* *align-maps*
4. Alignment Tool History *align-history* {{{1
ALIGN HISTORY {{{2
34 : Jul 08, 2008 * using :AlignCtrl before entering any alignment
control commands was causing an error.
33 : Sep 20, 2007 * s:Strlen() introduced to support various ways
used to represent characters and their effects
on string lengths. See |align-strlen|.
@ -1317,6 +1335,15 @@ ALIGN HISTORY {{{2
9 : Jun 25, 2002 : implemented cyclic padding
ALIGNMENT MAP HISTORY *alignmap-history* {{{2
v40 Oct 21, 2008 * Modified AlignMaps so that its maps use <Plug>s
and <script>s. \t@ and related maps have been
changed to call StdAlign() instead. The
WrapperStart function now takes an argument and
handles being called via visual mode. The
former nmaps and vmaps have thus been replaced
with a simple map.
Oct 24, 2008 * broke AlignMaps into a plugin and autoload
pair of scripts.
v39 Mar 06, 2008 : * \t= only does /* ... */ aligning when in *.c
*.cpp files.
v38 Aug 18, 2007 : * \tt altered so that it works with the new

View File

@ -1,4 +1,4 @@
*pi_netrw.txt* For Vim version 7.2. Last change: 2008 Sep 02
*pi_netrw.txt* For Vim version 7.2. Last change: 2008 Oct 23
-----------------------------------------------------
NETRW REFERENCE MANUAL by Charles E. Campbell, Jr.
@ -43,6 +43,7 @@
Changing To A Predecessor Directory................|netrw-u|
Changing To A Successor Directory..................|netrw-U|
Customizing Browsing With A User Function..........|netrw-x|
Deleting Bookmarks.................................|netrw-mB|
Deleting Files Or Directories......................|netrw-D|
Directory Exploring Commands.......................|netrw-explore|
Exploring With Stars and Patterns..................|netrw-star|
@ -159,16 +160,33 @@ EXTERNAL APPLICATIONS AND PROTOCOLS *netrw-externapp* {{{2
Protocol Variable Default Value
-------- ---------------- -------------
dav: *g:netrw_dav_cmd* = "cadaver"
fetch: *g:netrw_fetch_cmd* = "fetch -o" if fetch is available
ftp: *g:netrw_ftp_cmd* = "ftp"
http: *g:netrw_http_cmd* = "curl -o" if curl is available
http: g:netrw_http_cmd = "wget -q -O" elseif wget is available
http: g:netrw_http_cmd = "fetch -o" elseif fetch is available
rcp: *g:netrw_rcp_cmd* = "rcp"
rsync: *g:netrw_rsync_cmd* = "rsync -a"
scp: *g:netrw_scp_cmd* = "scp -q"
sftp: *g:netrw_sftp_cmd* = "sftp"
dav: *g:netrw_dav_cmd* = "cadaver" if cadaver is executable
dav: g:netrw_dav_cmd = "curl -o" elseif curl is available
fetch: *g:netrw_fetch_cmd* = "fetch -o" if fetch is available
ftp: *g:netrw_ftp_cmd* = "ftp"
http: *g:netrw_http_cmd* = "elinks" if elinks is available
http: g:netrw_http_cmd = "links" elseif links is available
http: g:netrw_http_cmd = "curl" elseif curl is available
http: g:netrw_http_cmd = "wget" elseif wget is available
http: g:netrw_http_cmd = "fetch" elseif fetch is available
rcp: *g:netrw_rcp_cmd* = "rcp"
rsync: *g:netrw_rsync_cmd* = "rsync -a"
scp: *g:netrw_scp_cmd* = "scp -q"
sftp: *g:netrw_sftp_cmd* = "sftp"
*g:netrw_http_xcmd* : the option string for http://... protocols are
specified via this variable and may be independently oveerridden.
elinks : "-dump >"
links : "-dump >"
curl : "-o"
wget : "-q -O"
fetch : "-o"
For example, if your system has elinks but you want to see the html
source in detail rather than a text rendering thereof, you may wish
to have let g:netrw_http_xcmd= "-source >" in your .vimrc.
READING *netrw-read* *netrw-nread* {{{2
@ -678,7 +696,8 @@ variables listed below, and may be modified by the user.
read via ftp automatically
transformed however they wish
by NetReadFixup()
g:netrw_dav_cmd variable ="cadaver"
g:netrw_dav_cmd variable ="cadaver" if cadaver is executable
g:netrw_dav_cmd variable ="curl -o" elseif curl is executable
g:netrw_fetch_cmd variable ="fetch -o" if fetch is available
g:netrw_ftp_cmd variable ="ftp"
g:netrw_http_cmd variable ="fetch -o" if fetch is available
@ -929,7 +948,7 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2
* the user doesn't already have a <2-leftmouse> mapping
defined before netrw is autoloaded,
then a double clicked leftmouse button will return
to the netrw browser window.
to the netrw browser window. See |g:netrw_retmap|.
<s-leftmouse> (gvim only) like mf, will mark files
*netrw-quickcom* *netrw-quickcoms*
@ -946,13 +965,18 @@ QUICK REFERENCE: COMMANDS *netrw-explore-cmds* *netrw-browse-cmds* {{{2
:Vexplore[!] [dir] Vertical Split & Explore...............|netrw-explore|
BOOKMARKING A DIRECTORY *netrw-mb* *netrw-bookmark* *netrw-bookmarks* {{{2
One may easily "bookmark" a directory by using >
{cnt}mb
mb
<
Any count may be used. One may use viminfo's "!" option (|'viminfo'|) to
retain bookmarks between vim sessions. See |netrw-gb| for how to return
to a bookmark and |netrw-qb| for how to list them.
Bookmarks are retained in between sesions in a $HOME/.netrwbook file, and are
kept in sorted order.
Related Topics:
|netrw-gb| how to return (go) to a bookmark
|netrw-mB| how to delete bookmarks
|netrw-qb| how to list bookmarks
BROWSING *netrw-cr* {{{2
@ -1085,8 +1109,12 @@ To change directory back to a bookmarked directory, use
{cnt}gb
Any count may be used to reference any of the bookmarks. See |netrw-mb| on
how to bookmark a directory and |netrw-qb| on how to list bookmarks.
Any count may be used to reference any of the bookmarks.
Related Topics:
|netrw-mB| how to delete bookmarks
|netrw-mb| how to return to a bookmark
|netrw-qb| how to list bookmarks
CHANGING TO A PREDECESSOR DIRECTORY *netrw-u* *netrw-updir* {{{2
@ -1191,6 +1219,18 @@ with a request.
Associated setting variable: |g:netrw_browsex_viewer|
*netrw-curdir*
DELETING BOOKMARKS *netrw-mB* {{{2
To delete a bookmark, use >
{cnt}mB
<
Related Topics:
|netrw-gb| how to return (go) to a bookmark
|netrw-mb| how to make a bookmark
|netrw-qb| how to list bookmarks
DELETING FILES OR DIRECTORIES *netrw-delete* *netrw-D* *netrw-del* {{{2
If files have not been marked with |netrw-mf|: (local marked file list)
@ -1232,12 +1272,12 @@ Associated setting variable: |g:netrw_local_rmdir| |g:netrw_rm_cmd|
*netrw-rexplore* *netrw-sexplore* *netrw-texplore* *netrw-vexplore*
DIRECTORY EXPLORATION COMMANDS {{{2
:Explore[!] [dir]... Explore directory of current file *:Explore*
:Hexplore[!] [dir]... Horizontal Split & Explore *:Hexplore*
:Rexplore ... Return to Explorer *:Rexplore*
:Sexplore[!] [dir]... Split&Explore directory of current file *:Sexplore*
:Texplore [dir]... Tab & Explore *:Texplore*
:Vexplore[!] [dir]... Vertical Split & Explore *:Vexplore*
:[N]Explore[!] [dir]... Explore directory of current file *:Explore*
:[N]Hexplore[!] [dir]... Horizontal Split & Explore *:Hexplore*
:Rexplore ... Return to Explorer *:Rexplore*
:[N]Sexplore[!] [dir]... Split&Explore current file's directory*:Sexplore*
:Texplore [dir]... Tab & Explore *:Texplore*
:[N]Vexplore[!] [dir]... Vertical Split & Explore *:Vexplore*
Used with :Explore **/pattern : (also see |netrw-starstar|)
:Nexplore............. go to next matching file *:Nexplore*
@ -1259,11 +1299,15 @@ DIRECTORY EXPLORATION COMMANDS {{{2
:Vexplore! [dir] does an :Explore with |:rightbelow| vertical splitting.
:Texplore [dir] does a tabnew before generating the browser window
By default, these commands use the current file's directory. However, one
may explicitly provide a directory (path) to use.
By default, these commands use the current file's directory. However, one may
explicitly provide a directory (path) to use.
The |g:netrw_winsize| variable also is used, if specified by the user, to
size Hexplore and Vexplore windows.
The [N] will override |g:netrw_winsize| to specify the quantity of rows and/or
columns the new explorer window should have.
Otherwise, the |g:netrw_winsize| variable, if it has been specified by the
user, is used to control the quantity of rows and/or columns new explorer
windows should have.
:Rexplore This command is a little different from the others. When one
edits a file, for example by pressing <cr> when atop a file in
@ -1508,11 +1552,15 @@ passwords:
LISTING BOOKMARKS AND HISTORY *netrw-qb* *netrw-listbookmark* {{{2
Pressing "qb" (query bookmarks) will list the bookmarked directories and
directory traversal history (query).
(see |netrw-mb|, |netrw-gb|, |netrw-u|, and |netrw-U|)
Pressing "qb" (query bookmarks) will list both the bookmarked directories and
directory traversal history.
Related Topics:
|netrw-gb| how to return (go) to a bookmark
|netrw-mb| how to make a bookmark
|netrw-mB| how to delete bookmarks
|netrw-u| change to a predecessor directory via the history stack
|netrw-U| change to a successor directory via the history stack
MAKING A NEW DIRECTORY *netrw-d* {{{2
@ -1865,6 +1913,12 @@ your browsing preferences. (see also: |netrw-settings|)
*g:netrw_hide* if true, the hiding list is used
default: =0
*g:netrw_home* The home directory for where bookmarks and
history are saved (as .netrwbook and
.netrwhist).
default: the first directory on the
|'runtimepath'|
*g:netrw_keepdir* =1 (default) keep current directory immune from
the browsing directory.
=0 keep the current directory the same as the
@ -1913,11 +1967,23 @@ your browsing preferences. (see also: |netrw-settings|)
*g:netrw_mkdir_cmd* command for making a remote directory
default: "ssh USEPORT HOSTNAME mkdir"
*g:netrw_retmap* if it exists and is set to one, then
<2-leftmouse> will be mapped for easy
*g:netrw_retmap* if it exists and is set to one, then:
* if in a netrw-selected file, AND
* no normal-mode <2-leftmouse> mapping exists,
then the <2-leftmouse> will be mapped for easy
return to the netrw browser window.
(example: click once to select and open
a file, double-click to return)
example: click once to select and open a file,
double-click to return.
Note that one may instead choose to:
* let g:netrw_retmap= 1, AND
* nmap <silent> YourChoice <Plug>NetrwReturn
and have another mapping instead of
<2-leftmouse> to invoke the return.
You may also use the |:Rexplore| command to do
the same thing.
default: =0
*g:netrw_rm_cmd* command for removing files
@ -2439,10 +2505,33 @@ which is loaded automatically at startup (assuming :set nocp).
==============================================================================
12. History *netrw-history* {{{1
v134: Sep 30, 2008 * (Sander Marechal) provided a bugfix involving
the use of the |netrw-t| command with a remote
directory.
Sep 30, 2008 * using "x" on a remote jpg was failing; fixed.
Oct 03, 2008 * bookmarks now go on a list and are stored to
the first directory on the |'runtimepath'| in
the hopes of making their retention reliable.
History now also goes to that directory.
Oct 07, 2008 * Included check that vim 7.0 or later is in use.
Oct 07, 2008 * Improved |g:netrw_retmap| handling.
Oct 12, 2008 * Based upon Sébastien Migniot's suggestion, if
cadaver isn't available then netrw will try to
use curl for the dav://... protocol.
Oct 13, 2008 * added @*/ to netrw buffers' |'iskeyword'|setting
This lets mf (|netrw-mf|) mark directories, links
and executables.
Oct 13, 2008 * avoids a second NetrwBrowse() refresh when
g:netrw_fastbrowse is <= 1 (slow, medium speed)
Oct 22, 2008 * |g:netrw_http_xcmd| may now be overridden
independently of |g:netrw_http_cmd|.
Oct 23, 2008 * [N] added to the various Explore commands to
let users specify the width/height of new
explorer windows, overriding |g:netrw_winsize|.
v133: Aug 10, 2008 * NetReadFixup() for win95 was missing some "a:"s
Aug 12, 2008 * (Jan Minář) an error condition in NetrwMethod()
wasn't being used, resulting in b:netrw_fname
undefined errors
wasn't being used, resulting in "b:netrw_fname
undefined" errors
Aug 12, 2008 * (François Ingeirest) asked that "hi link" be
changed to hi default link in the netrw syntax
files.

View File

@ -1,4 +1,3 @@
'go' Align.txt /*'go'*
:Explore pi_netrw.txt /*:Explore*
:GLVS pi_getscript.txt /*:GLVS*
:GetLatestVimScripts_dat pi_getscript.txt /*:GetLatestVimScripts_dat*
@ -32,7 +31,6 @@
:RmVimball pi_vimball.txt /*:RmVimball*
:Search MultipleSearch.txt /*:Search*
:SearchBuffers MultipleSearch.txt /*:SearchBuffers*
:Sexplore pi_netrw.txt /*:Sexplore*
:TComment tComment.txt /*:TComment*
:TCommentAs tComment.txt /*:TCommentAs*
:TCommentBlock tComment.txt /*:TCommentBlock*
@ -84,6 +82,7 @@ align-control Align.txt /*align-control*
align-history Align.txt /*align-history*
align-manual Align.txt /*align-manual*
align-maps Align.txt /*align-maps*
align-multibyte Align.txt /*align-multibyte*
align-option Align.txt /*align-option*
align-options Align.txt /*align-options*
align-strlen Align.txt /*align-strlen*
@ -1444,7 +1443,9 @@ g:netrw_ftp_timelist_cmd pi_netrw.txt /*g:netrw_ftp_timelist_cmd*
g:netrw_ftpmode pi_netrw.txt /*g:netrw_ftpmode*
g:netrw_glob_escape pi_netrw.txt /*g:netrw_glob_escape*
g:netrw_hide pi_netrw.txt /*g:netrw_hide*
g:netrw_home pi_netrw.txt /*g:netrw_home*
g:netrw_http_cmd pi_netrw.txt /*g:netrw_http_cmd*
g:netrw_http_xcmd pi_netrw.txt /*g:netrw_http_xcmd*
g:netrw_ignorenetrc pi_netrw.txt /*g:netrw_ignorenetrc*
g:netrw_keepdir pi_netrw.txt /*g:netrw_keepdir*
g:netrw_list_cmd pi_netrw.txt /*g:netrw_list_cmd*
@ -1492,6 +1493,7 @@ g:tcommentMapLeaderOp1 tComment.txt /*g:tcommentMapLeaderOp1*
g:tcommentMapLeaderOp2 tComment.txt /*g:tcommentMapLeaderOp2*
g:tcommentOpModeExtra tComment.txt /*g:tcommentOpModeExtra*
g:vimball_home pi_vimball.txt /*g:vimball_home*
g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir*
g:vimball_path_escape pi_vimball.txt /*g:vimball_path_escape*
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
getlatestvimscripts-install pi_getscript.txt /*getlatestvimscripts-install*
@ -1619,6 +1621,7 @@ netrw-list pi_netrw.txt /*netrw-list*
netrw-listbookmark pi_netrw.txt /*netrw-listbookmark*
netrw-listhack pi_netrw.txt /*netrw-listhack*
netrw-login pi_netrw.txt /*netrw-login*
netrw-mB pi_netrw.txt /*netrw-mB*
netrw-mT pi_netrw.txt /*netrw-mT*
netrw-mb pi_netrw.txt /*netrw-mb*
netrw-mc pi_netrw.txt /*netrw-mc*
@ -1742,6 +1745,7 @@ vimball pi_vimball.txt /*vimball*
vimball-contents pi_vimball.txt /*vimball-contents*
vimball-extract pi_vimball.txt /*vimball-extract*
vimball-history pi_vimball.txt /*vimball-history*
vimball-intro pi_vimball.txt /*vimball-intro*
vimball-manual pi_vimball.txt /*vimball-manual*
viscinr-I visincr.txt /*viscinr-I*
viscinr-contents visincr.txt /*viscinr-contents*

View File

@ -1,506 +0,0 @@
" AlignMaps: Alignment maps based upon <Align.vim>
" Maintainer: Dr. Charles E. Campbell, Jr. <Charles.Campbell@gsfc.nasa.gov>
" Date: Mar 06, 2008
" Version: 39
"
" NOTE: the code herein needs vim 6.0 or later
" needs <Align.vim> v6 or later
" needs <cecutil.vim> v5 or later
" Copyright: Copyright (C) 1999-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,
" AlignMaps.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.
"
" Usage: {{{1
" Use 'a to mark beginning of to-be-aligned region, Alternative: use v
" move cursor to end of region, and execute map. (visual mode) to mark
" The maps also set up marks 'y and 'z, and retain region, execute same map.
" 'a at the beginning of region. Uses 'a, 'y, and 'z.
"
" Although the comments indicate the maps use a leading backslash,
" actually they use <Leader> (:he mapleader), so the user can
" specify that the maps start how he or she prefers.
"
" Note: these maps all use <Align.vim>.
"
" Romans 1:20 For the invisible things of Him since the creation of the {{{1
" world are clearly seen, being perceived through the things that are
" made, even His everlasting power and divinity; that they may be
" without excuse.
" ---------------------------------------------------------------------
" Load Once: {{{1
if exists("g:loaded_alignmaps") || &cp
finish
endif
let g:loaded_alignmaps = "v39"
let s:keepcpo = &cpo
set cpo&vim
" ---------------------------------------------------------------------
" WS: wrapper start map (internal) {{{1
" Produces a blank line above and below, marks with 'y and 'z
if !hasmapto('<Plug>WrapperStart')
nmap <unique> <SID>WS <Plug>AlignMapsWrapperStart
endif
nmap <silent> <script> <Plug>AlignMapsWrapperStart :set lz<CR>:call AlignWrapperStart()<CR>
" ---------------------------------------------------------------------
" AlignWrapperStart: {{{1
fun! AlignWrapperStart()
" call Dfunc("AlignWrapperStart()")
if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0
" call Decho("wrapper initialization")
let s:alignmaps_wrapcnt = 1
let s:alignmaps_keepgd = &gdefault
let s:alignmaps_keepsearch = @/
let s:alignmaps_keepch = &ch
let s:alignmaps_keepmy = SaveMark("'y")
let s:alignmaps_keepmz = SaveMark("'z")
let s:alignmaps_posn = SaveWinPosn(0)
" set up fencepost blank lines
put =''
norm! mz'a
put! =''
ky
let s:alignmaps_zline = line("'z")
exe "'y,'zs/@/\177/ge"
else
" call Decho("embedded wrapper")
let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1
norm! 'yjma'zk
endif
" change some settings to align-standard values
set nogd
set ch=2
AlignPush
norm! 'zk
" call Dret("AlignWrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
endfun
" ---------------------------------------------------------------------
" WE: wrapper end (internal) {{{1
" Removes guard lines, restores marks y and z, and restores search pattern
if !hasmapto('<Plug>WrapperEnd')
nmap <unique> <SID>WE <Plug>AlignMapsWrapperEnd
endif
nmap <silent> <script> <Plug>AlignMapsWrapperEnd :call AlignWrapperEnd()<CR>:set nolz<CR>
" ---------------------------------------------------------------------
" AlignWrapperEnd: {{{1
fun! AlignWrapperEnd()
" call Dfunc("AlignWrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
" remove trailing white space introduced by whatever in the modification zone
'y,'zs/ \+$//e
" restore AlignCtrl settings
AlignPop
let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1
if s:alignmaps_wrapcnt <= 0
" initial wrapper ending
exe "'y,'zs/\177/@/ge"
" if the 'z line hasn't moved, then go ahead and restore window position
let zstationary= s:alignmaps_zline == line("'z")
" remove fencepost blank lines.
" restore 'a
norm! 'yjmakdd'zdd
" restore original 'y, 'z, and window positioning
call RestoreMark(s:alignmaps_keepmy)
call RestoreMark(s:alignmaps_keepmz)
if zstationary > 0
call RestoreWinPosn(s:alignmaps_posn)
" call Decho("restored window positioning")
endif
" restoration of options
let &gd= s:alignmaps_keepgd
let &ch= s:alignmaps_keepch
let @/ = s:alignmaps_keepsearch
" remove script variables
unlet s:alignmaps_keepch
unlet s:alignmaps_keepsearch
unlet s:alignmaps_keepmy
unlet s:alignmaps_keepmz
unlet s:alignmaps_keepgd
unlet s:alignmaps_posn
endif
" call Dret("AlignWrapperEnd : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
endfun
" ---------------------------------------------------------------------
" Complex C-code alignment maps: {{{1
map <silent> <Leader>a? <SID>WS:AlignCtrl mIp1P1lC ? : : : : <CR>:'a,.Align<CR>:'a,'z-1s/\(\s\+\)? /?\1/e<CR><SID>WE
map <silent> <Leader>a, <SID>WS:'y,'zs/\(\S\)\s\+/\1 /ge<CR>'yjma'zk<Leader>jnr,<CR>:silent 'y,'zg/,/call <SID>FixMultiDec()<CR>'z<Leader>adec<SID>WE
map <silent> <Leader>a< <SID>WS:AlignCtrl mIp1P1=l << >><CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>a= <SID>WS:AlignCtrl mIp1P1=l<CR>:AlignCtrl g :=<CR>:'a,'zAlign :\==<CR><SID>WE
map <silent> <Leader>abox <SID>WS:let g:alignmaps_iws=substitute(getline("'a"),'^\(\s*\).*$','\1','e')<CR>:'a,'z-1s/^\s\+//e<CR>:'a,'z-1s/^.*$/@&@/<CR>:AlignCtrl m=p01P0w @<CR>:'a,.Align<CR>:'a,'z-1s/@/ * /<CR>:'a,'z-1s/@$/*/<CR>'aYP:s/./*/g<CR>0r/'zkYp:s/./*/g<CR>0r A/<Esc>:exe "'a-1,'z-1s/^/".g:alignmaps_iws."/e"<CR><SID>WE
map <silent> <Leader>acom <SID>WS:'a,.s/\/[*/]\/\=/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:'y,'zs/^\( *\) @/\1@/e<CR>'zk<Leader>tW@:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <Leader>adcom <SID>WS:'a,.v/^\s*\/[/*]/s/\/[*/]\*\=/@&@/e<CR>:'a,.v/^\s*\/[/*]/s/\*\//@&/e<CR>:'y,'zv/^\s*\/[/*]/s/^\( *\) @/\1@/e<CR>'zk<Leader>tdW@:'y,'zv/^\s*\/[/*]/s/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <Leader>aocom :AlignPush<CR>:AlignCtrl g /[*/]<CR><Leader>acom:AlignPop<CR>
map <silent> <Leader>ascom <SID>WS:'a,.s/\/[*/]/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:silent! 'a,.g/^\s*@\/[*/]/s/@//ge<CR>:AlignCtrl v ^\s*\/[*/]<CR>:AlignCtrl g \/[*/]<CR>'zk<Leader>tW@:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <Leader>adec <SID>WS:'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR>:'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR>:'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR>:'y,'zv/^\s*[*/]/s/^\(\s*\%(\K\k*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\)\([*(&]*\)\s*\([a-zA-Z0-9_()]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\=\s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR>:'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR>:'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR>:'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR>'yjma'zk:AlignCtrl v ^\s*[*/#]<CR><Leader>t@:'y,'zv/^\s*[*/]/s/@ //ge<CR>:'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR>:'y,'zv/^#/s/# //e<CR>:'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR>:'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR>:'y,'zs/^[*]/ */e<CR><SID>WE
map <silent> <Leader>adef <SID>WS:AlignPush<CR>:AlignCtrl v ^\s*\(\/\*\<bar>\/\/\)<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/^\(\s*\)#\(\s\)*define\s*\(\I[a-zA-Z_0-9(),]*\)\s*\(.\{-}\)\($\<Bar>\/\*\)/#\1\2define @\3@\4@\5/e<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/\($\<Bar>\*\/\)/@&/e<CR>'zk<Leader>t@'yjma'zk:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/ @//g<CR><SID>WE
map <silent> <Leader>afnc :set lz<CR>:silent call <SID>Afnc()<CR>:set nolz<CR>
if exists("g:alignmaps_usanumber")
" map <silent> <Leader>anum <SID>WS
" \:'a,'zs/\([-+]\)\=\(\d\+\%([eE][-+]\=\d\+\)\=\)\ze\%($\|[^@]\)/@\1@\2@@#/ge<CR>
" \:'a,'zs/\([-+]\)\=\(\d*\)\(\.\)\(\d*\([eE][-+]\=\d\+\)\=\)/@\1@\2@\3@\4#/ge<CR>
" \:AlignCtrl mp0P0r<CR>
" \:'a,'zAlign [@#]<CR>
" \:'a,'zs/@//ge<CR>
" \:'a,'zs/#/ /ge<CR>
" \<SID>WE
map <silent> <Leader>anum <SID>WS:'a,'zs/\([0-9.]\)\s\+\zs\([-+]\=\d\)/@\1/ge<CR>
\:'a,'zs/\.@/\.0@/ge<CR>
\:AlignCtrl mp0P0r<CR>
\:'a,'zAlign [.@]<CR>
\:'a,'zs/@/ /ge<CR>
\:'a,'zs/\(\.\)\(\s\+\)\([0-9.,eE+]\+\)/\1\3\2/ge<CR>
\:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR>
\<SID>WE
elseif exists("g:alignmaps_euronumber")
map <silent> <Leader>anum <SID>WS:'a,'zs/\([0-9.]\)\s\+\([-+]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [,@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(,\)\(\s\+\)\([-0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
else
map <silent> <Leader>anum <SID>WS:'a,'zs/\([0-9.]\)\s\+\([-+]\=[.,]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0<CR>:'a,'zAlign [.,@]<CR>:'a,'zs/\([-0-9.,]*\)\(\s*\)\([.,]\)/\2\1\3/g<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
endif
map <silent> <Leader>aunum <SID>WS:'a,'zs/\([0-9.]\)\s\+\([-+]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [.@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(\.\)\(\s\+\)\([-0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
map <silent> <Leader>aenum <SID>WS:'a,'zs/\([0-9.]\)\s\+\([-+]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [,@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(,\)\(\s\+\)\([-0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
" ---------------------------------------------------------------------
" html table alignment {{{1
map <silent> <Leader>Htd <SID>WS:'y,'zs%<[tT][rR]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]></[tT][rR]>%@&@%g<CR>'yjma'zk:AlignCtrl m=Ilp1P0 @<CR>:'a,.Align<CR>:'y,'zs/ @/@/<CR>:'y,'zs/@ <[tT][rR]>/<[tT][rR]>/ge<CR>:'y,'zs/@//ge<CR><SID>WE
" ---------------------------------------------------------------------
" character-based right-justified alignment maps {{{1
map <silent> <Leader>T| <SID>WS:AlignCtrl mIp0P0=r <Bar><CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>T# <SID>WS:AlignCtrl mIp0P0=r #<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>T, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>Ts, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR>:'a,.s/\(\s*\),/,\1/ge<CR><SID>WE
map <silent> <Leader>T: <SID>WS:AlignCtrl mIp1P1=r :<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>T; <SID>WS:AlignCtrl mIp0P0=r ;<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>T< <SID>WS:AlignCtrl mIp0P0=r <<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>T= <SID>WS:'a,'z-1s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'z-1s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'z-1s/; */;@/e<CR>:'a,'z-1s/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'z-1s/!=/\x="!\<Char-0xff>"/ge<CR>:AlignCtrl mIp1P1=r = @<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s/; *@/;/e<CR>:'a,'z-1s/; *$/;/e<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-1s/\xff/=/ge<CR><SID>WE<Leader>acom
map <silent> <Leader>T? <SID>WS:AlignCtrl mIp0P0=r ?<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <Leader>T@ <SID>WS:AlignCtrl mIp0P0=r @<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>Tab <SID>WS:'a,.s/^\(\t*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\t','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <Leader>Tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <Leader>T~ <SID>WS:AlignCtrl mIp0P0=r ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
" ---------------------------------------------------------------------
" character-based left-justified alignment maps {{{1
map <silent> <Leader>t| <SID>WS:AlignCtrl mIp0P0=l <Bar><CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>t# <SID>WS:AlignCtrl mIp0P0=l #<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>t, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>ts, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR>:'a,.s/\(\s*\),/,\1/ge<CR><SID>WE
map <silent> <Leader>t: <SID>WS:AlignCtrl mIp1P1=l :<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>t; <SID>WS:AlignCtrl mIp0P1=l ;<CR>:'a,.Align<CR>:'y,'zs/\( *\);/;\1/ge<CR><SID>WE
map <silent> <Leader>t< <SID>WS:AlignCtrl mIp0P0=l <<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>t= <SID>WS:call <SID>Equals()<CR><SID>WE
map <silent> <Leader>w= <SID>WS:'a,'zg/=/s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zg/=/s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zg/=/s/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zg/=/s/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mWp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1g/=/Align<CR>:'a,'z-1g/=/s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1g/=/s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk<Leader>t@:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1g/=/s/\xff/=/ge<CR>:'y,'zg/=/s/ @//eg<CR><SID>WE
map <silent> <Leader>t? <SID>WS:AlignCtrl mIp0P0=l ?<CR>:'a,.Align<CR>:.,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <Leader>t~ <SID>WS:AlignCtrl mIp0P0=l ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <Leader>m= <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zs/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-s/%\ze[^=]/ @%@ /e<CR>'zk<Leader>t@:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/\xff/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <Leader>tab <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0xff>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0xff>"<bar>else<bar>exe "AlignCtrl mI=l \<Char-0xff>"<bar>endif<CR>:'a,.Align<CR>:exe "'y+1,'z-1s/\<Char-0xff>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE
map <silent> <Leader>tml <SID>WS:AlignCtrl mWp1P0=l \\\@<!\\\s*$<CR>:'a,.Align<CR><SID>WE
map <silent> <Leader>tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <Leader>tsq <SID>WS:'a,.AlignReplaceQuotedSpaces<CR>:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).substitute(submatch(2),'\s\+','@','g')/<CR>:AlignCtrl mIp0P0=l @<CR>:'a,.Align<CR>:'y+1,'z-1s/[%@]/ /g<CR><SID>WE
map <silent> <Leader>tt <SID>WS:AlignCtrl mIp1P1=l \\\@<!& \\\\<CR>:'a,.Align<CR><SID>WE
" ---------------------------------------------------------------------
" plain Align maps; these two are used in <Leader>acom..\afnc {{{1
map <silent> <Leader>t@ :AlignCtrl mIp1P1=l @<CR>:'a,.Align<CR>
map <silent> <Leader>tW@ :AlignCtrl mWp1P1=l @<CR>:'a,.Align<CR>
map <silent> <Leader>tdW@ :AlignCtrl v ^\s*/[/*]<CR>:AlignCtrl mWp1P1=l @<CR>:'a,.Align<CR>
" ---------------------------------------------------------------------
" Joiner : maps used above {{{1
map <silent> <Leader>jnr= :call <SID>CharJoiner("=")<CR>
map <silent> <Leader>jnr, :call <SID>CharJoiner(",")<CR>
" ---------------------------------------------------------------------
" visual-line mode variants: {{{1
vmap <silent> <Leader>T| :<BS><BS><BS><CR>ma'><Leader>T|
vmap <silent> <Leader>T, :<BS><BS><BS><CR>ma'><Leader>T,
vmap <silent> <Leader>Ts, :<BS><BS><BS><CR>ma'><Leader>Ts,
vmap <silent> <Leader>T: :<BS><BS><BS><CR>ma'><Leader>T:
vmap <silent> <Leader>T< :<BS><BS><BS><CR>ma'><Leader>T<
vmap <silent> <Leader>T= :<BS><BS><BS><CR>ma'><Leader>T=
vmap <silent> <Leader>T@ :<BS><BS><BS><CR>ma'><Leader>T@
vmap <silent> <Leader>Tsp :<BS><BS><BS><CR>ma'><Leader>Tsp
vmap <silent> <Leader>a? :<BS><BS><BS><CR>ma'><Leader>a?
vmap <silent> <Leader>a, :<BS><BS><BS><CR>ma'><Leader>a,
vmap <silent> <Leader>a< :<BS><BS><BS><CR>ma'><Leader>a<
vmap <silent> <Leader>a= :<BS><BS><BS><CR>ma'><Leader>a=
vmap <silent> <Leader>abox :<BS><BS><BS><CR>ma'><Leader>abox
vmap <silent> <Leader>acom :<BS><BS><BS><CR>ma'><Leader>acom
vmap <silent> <Leader>aocom :<BS><BS><BS><CR>ma'><Leader>aocom
vmap <silent> <Leader>ascom :<BS><BS><BS><CR>ma'><Leader>ascom
vmap <silent> <Leader>adec :<BS><BS><BS><CR>ma'><Leader>adec
vmap <silent> <Leader>adef :<BS><BS><BS><CR>ma'><Leader>adef
vmap <silent> <Leader>afnc :<BS><BS><BS><CR>ma'><Leader>afnc
vmap <silent> <Leader>anum :<BS><BS><BS><CR>ma'><Leader>anum
"vmap <silent> <Leader>anum :B s/\(\d\)\s\+\(-\=[.,]\=\d\)/\1@\2/ge<CR>:AlignCtrl mp0P0<CR>gv:Align [.,@]<CR>:'<,'>s/\([-0-9.,]*\)\(\s\+\)\([.,]\)/\2\1\3/ge<CR>:'<,'>s/@/ /ge<CR>
vmap <silent> <Leader>t| :<BS><BS><BS><CR>ma'><Leader>t|
vmap <silent> <Leader>t, :<BS><BS><BS><CR>ma'><Leader>t,
vmap <silent> <Leader>ts, :<BS><BS><BS><CR>ma'><Leader>ts,
vmap <silent> <Leader>t: :<BS><BS><BS><CR>ma'><Leader>t:
vmap <silent> <Leader>t; :<BS><BS><BS><CR>ma'><Leader>t;
vmap <silent> <Leader>t< :<BS><BS><BS><CR>ma'><Leader>t<
vmap <silent> <Leader>t= :<BS><BS><BS><CR>ma'><Leader>t=
vmap <silent> <Leader>t? :<BS><BS><BS><CR>ma'><Leader>t?
vmap <silent> <Leader>t@ :<BS><BS><BS><CR>ma'><Leader>t@
vmap <silent> <Leader>tab :<BS><BS><BS><CR>ma'><Leader>tab
vmap <silent> <Leader>tml :<BS><BS><BS><CR>ma'><Leader>tml
vmap <silent> <Leader>tsp :<BS><BS><BS><CR>ma'><Leader>tsp
vmap <silent> <Leader>tsq :<BS><BS><BS><CR>ma'><Leader>tsq
vmap <silent> <Leader>tp@ :<BS><BS><BS><CR>ma'><Leader>tp@
vmap <silent> <Leader>tt :<BS><BS><BS><CR>ma'><Leader>tt
vmap <silent> <Leader>Htd :<BS><BS><BS><CR>ma'><Leader>Htd
" ---------------------------------------------------------------------
" Menu Support: {{{1
" ma ..move.. use menu
" v V or ctrl-v ..move.. use menu
if has("menu") && has("gui_running") && &go =~ 'm' && !exists("s:firstmenu")
let s:firstmenu= 1
if !exists("g:DrChipTopLvlMenu")
let g:DrChipTopLvlMenu= "DrChip."
endif
if g:DrChipTopLvlMenu != ""
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.<<\ and\ >> <Leader>a<'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ = <Leader>t='
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ := <Leader>a='
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Backslashes <Leader>tml'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Breakup\ Comma\ Declarations <Leader>a,'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.C\ Comment\ Box <Leader>abox'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas <Leader>t,'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas <Leader>ts,'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas\ With\ Strings <Leader>tsq'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments <Leader>acom'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments\ Only <Leader>aocom'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declaration\ Comments <Leader>adcom'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declarations <Leader>adec'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Definitions <Leader>adef'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Function\ Header <Leader>afnc'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Html\ Tables <Leader>Htd'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.(\.\.\.)?\.\.\.\ :\ \.\.\. <Leader>a?'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers <Leader>anum'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (American-Style) <Leader>aunum <Leader>aunum'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (Euro-Style) <Leader>aenum'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Left\ Justified) <Leader>tsp'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Right\ Justified) <Leader>Tsp'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Statements\ With\ Percent\ Style\ Comments <Leader>m='
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ < <Leader>t<'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ \| <Leader>t|'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ @ <Leader>t@'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ # <Leader>t#'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Tabs <Leader>tab'
endif
endif
" ---------------------------------------------------------------------
" CharJoiner: joins lines which end in the given character (spaces {{{1
" at end are ignored)
fun! <SID>CharJoiner(chr)
" call Dfunc("CharJoiner(chr=".a:chr.")")
let aline = line("'a")
let rep = line(".") - aline
while rep > 0
norm! 'a
while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0
" while = at end-of-line, delete it and join with next
norm! 'a$
j!
let rep = rep - 1
endwhile
" update rep(eat) count
let rep = rep - 1
if rep <= 0
" terminate loop if at end-of-block
break
endif
" prepare for next line
norm! jma
let aline = line("'a")
endwhile
" call Dret("CharJoiner")
endfun
" ---------------------------------------------------------------------
" s:Equals: {{{2
fun! s:Equals()
" call Dfunc("s:Equals()")
'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e
'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge
'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge
'a,'zs/!=/\="!\<Char-0xff>"/ge
norm g'zk
AlignCtrl mIp1P1=l =
AlignCtrl g =
'a,'z-1Align
'a,'z-1s@\([*/+\-%|&\~^!=]\)\( \+\)=@\2\1=@ge
'a,'z-1s/\( \+\);/;\1/ge
if &ft == "c" || &ft == "cpp"
'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e
'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e
exe norm "'zk<Leader>t@"
'y,'zs/^\(\s*\) @/\1/e
endif
'a,'z-1s/<Char-0xff>/=/ge
'y,'zs/ @//eg
" call Dret("s:Equals")
endfun
" ---------------------------------------------------------------------
" Afnc: useful for splitting one-line function beginnings {{{1
" into one line per argument format
fun! s:Afnc()
" call Dfunc("Afnc()")
" keep display quiet
let chkeep = &ch
let gdkeep = &gd
let vekeep = &ve
set ch=2 nogd ve=
" will use marks y,z ; save current values
let mykeep = SaveMark("'y")
let mzkeep = SaveMark("'z")
" Find beginning of function -- be careful to skip over comments
let cmmntid = synIDtrans(hlID("Comment"))
let stringid = synIDtrans(hlID("String"))
exe "norm! ]]"
while search(")","bW") != 0
" call Decho("line=".line(".")." col=".col("."))
let parenid= synIDtrans(synID(line("."),col("."),1))
if parenid != cmmntid && parenid != stringid
break
endif
endwhile
norm! %my
s/(\s*\(\S\)/(\r \1/e
exe "norm! `y%"
s/)\s*\(\/[*/]\)/)\r\1/e
exe "norm! `y%mz"
'y,'zs/\s\+$//e
'y,'zs/^\s\+//e
'y+1,'zs/^/ /
" insert newline after every comma only one parenthesis deep
sil! exe "norm! `y\<right>h"
let parens = 1
let cmmnt = 0
let cmmntline= -1
while parens >= 1
" call Decho("parens=".parens." @a=".@a)
exe 'norm! ma "ay`a '
if @a == "("
let parens= parens + 1
elseif @a == ")"
let parens= parens - 1
" comment bypass: /* ... */ or //...
elseif cmmnt == 0 && @a == '/'
let cmmnt= 1
elseif cmmnt == 1
if @a == '/'
let cmmnt = 2 " //...
let cmmntline= line(".")
elseif @a == '*'
let cmmnt= 3 " /*...
else
let cmmnt= 0
endif
elseif cmmnt == 2 && line(".") != cmmntline
let cmmnt = 0
let cmmntline= -1
elseif cmmnt == 3 && @a == '*'
let cmmnt= 4
elseif cmmnt == 4
if @a == '/'
let cmmnt= 0 " ...*/
elseif @a != '*'
let cmmnt= 3
endif
elseif @a == "," && parens == 1 && cmmnt == 0
exe "norm! i\<CR>\<Esc>"
endif
endwhile
norm! `y%mz%
sil! 'y,'zg/^\s*$/d
" perform substitutes to mark fields for Align
sil! 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e
sil! 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg
sil! 'y+1,'zv/^\//s/\* \+/*/ge
" func
" ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end->
sil! 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e
sil! 'y+1,'z+1g/^\s*\/[*/]/norm! kJ
sil! 'y+1,'z+1s%/[*/]%@&@%ge
sil! 'y+1,'z+1s%*/%@&%ge
AlignCtrl mIp0P0=l @
sil! 'y+1,'zAlign
sil! 'y,'zs%@\(/[*/]\)@%\t\1 %e
sil! 'y,'zs%@\*/% */%e
sil! 'y,'zs/@\([,)]\)/\1/
sil! 'y,'zs/@/ /
AlignCtrl mIlrp0P0= # @
sil! 'y+1,'zAlign
sil! 'y+1,'zs/#/ /
sil! 'y+1,'zs/@//
sil! 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e
" Restore
call RestoreMark(mykeep)
call RestoreMark(mzkeep)
let &ch= chkeep
let &gd= gdkeep
let &ve= vekeep
" call Dret("Afnc")
endfun
" ---------------------------------------------------------------------
" FixMultiDec: converts a type arg,arg,arg; line to multiple lines {{{1
fun! s:FixMultiDec()
" call Dfunc("FixMultiDec()")
" save register x
let xkeep = @x
let curline = getline(".")
" call Decho("curline<".curline.">")
" Get the type. I'm assuming one type per line (ie. int x; double y; on one line will not be handled properly)
let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9_ \t]*\)\s\+[(*]*\h.*$','\1','')
" call Decho("@x<".@x.">")
" transform line
exe 's/,/;\r'.@x.' /ge'
"restore register x
let @x= xkeep
" call Dret("FixMultiDec : my=".line("'y")." mz=".line("'z"))
endfun
let &cpo= s:keepcpo
unlet s:keepcpo
" ------------------------------------------------------------------------------
" vim: ts=4 nowrap fdm=marker

View File

@ -0,0 +1,230 @@
" AlignMapsPlugin: Alignment maps based upon <Align.vim> and <AlignMaps.vim>
" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
" Date: Oct 24, 2008
"
" NOTE: the code herein needs vim 6.0 or later
" needs <Align.vim> v6 or later
" needs <cecutil.vim> v5 or later
" Copyright: Copyright (C) 1999-2008 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,
" AlignMaps.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.
"
" Usage: {{{1
" Use 'a to mark beginning of to-be-aligned region, Alternative: use V
" move cursor to end of region, and execute map. (linewise visual mode) to
" The maps also set up marks 'y and 'z, and retain mark region, execute same
" 'a at the beginning of region. map. Uses 'a, 'y, and 'z.
"
" The start/end wrappers save and restore marks 'y and 'z.
"
" Although the comments indicate the maps use a leading backslash,
" actually they use <Leader> (:he mapleader), so the user can
" specify that the maps start how he or she prefers.
"
" Note: these maps all use <Align.vim>.
"
" Romans 1:20 For the invisible things of Him since the creation of the {{{1
" world are clearly seen, being perceived through the things that are
" made, even His everlasting power and divinity; that they may be
" without excuse.
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp
finish
endif
let s:keepcpo= &cpo
set cpo&vim
" =====================================================================
" Maps: {{{1
" ---------------------------------------------------------------------
" WS: wrapper start map (internal) {{{2
" Produces a blank line above and below, marks with 'y and 'z
if !hasmapto('<Plug>WrapperStart')
map <unique> <SID>WS <Plug>AlignMapsWrapperStart
endif
nmap <silent> <script> <Plug>AlignMapsWrapperStart :set lz<CR>:call AlignMaps#WrapperStart(0)<CR>
vmap <silent> <script> <Plug>AlignMapsWrapperStart :<c-u>set lz<CR>:call AlignMaps#WrapperStart(1)<CR>
" ---------------------------------------------------------------------
" WE: wrapper end (internal) {{{2
" Removes guard lines, restores marks y and z, and restores search pattern
if !hasmapto('<Plug>WrapperEnd')
nmap <unique> <SID>WE <Plug>AlignMapsWrapperEnd
endif
nmap <silent> <script> <Plug>AlignMapsWrapperEnd :call AlignMaps#WrapperEnd()<CR>:set nolz<CR>
" ---------------------------------------------------------------------
" Complex C-code alignment maps: {{{2!= ""
if !hasmapto('<Plug>AM_a?') |map <unique> <Leader>a? <Plug>AM_a?|endif
if !hasmapto('<Plug>AM_a,') |map <unique> <Leader>a, <Plug>AM_a,|endif
if !hasmapto('<Plug>AM_a<') |map <unique> <Leader>a< <Plug>AM_a<|endif
if !hasmapto('<Plug>AM_a=') |map <unique> <Leader>a= <Plug>AM_a=|endif
if !hasmapto('<Plug>AM_abox') |map <unique> <Leader>abox <Plug>AM_abox|endif
if !hasmapto('<Plug>AM_acom') |map <unique> <Leader>acom <Plug>AM_acom|endif
if !hasmapto('<Plug>AM_adcom')|map <unique> <Leader>adcom <Plug>AM_adcom|endif
if !hasmapto('<Plug>AM_aocom')|map <unique> <Leader>aocom <Plug>AM_aocom|endif
if !hasmapto('<Plug>AM_ascom')|map <unique> <Leader>ascom <Plug>AM_ascom|endif
if !hasmapto('<Plug>AM_adec') |map <unique> <Leader>adec <Plug>AM_adec|endif
if !hasmapto('<Plug>AM_adef') |map <unique> <Leader>adef <Plug>AM_adef|endif
if !hasmapto('<Plug>AM_afnc') |map <unique> <Leader>afnc <Plug>AM_afnc|endif
if !hasmapto('<Plug>AM_afnc') |map <unique> <Leader>afnc <Plug>AM_afnc|endif
if !hasmapto('<Plug>AM_aunum')|map <unique> <Leader>aunum <Plug>AM_aenum|endif
if !hasmapto('<Plug>AM_aenum')|map <unique> <Leader>aenum <Plug>AM_aunum|endif
if exists("g:alignmaps_euronumber") && !exists("g:alignmaps_usanumber")
if !hasmapto('<Plug>AM_anum')|map <unique> <Leader>anum <Plug>AM_aenum|endif
else
if !hasmapto('<Plug>AM_anum')|map <unique> <Leader>anum <Plug>AM_aunum|endif
endif
map <silent> <script> <Plug>AM_a? <SID>WS:AlignCtrl mIp1P1lC ? : : : : <CR>:'a,.Align<CR>:'a,'z-1s/\(\s\+\)? /?\1/e<CR><SID>WE
map <silent> <script> <Plug>AM_a, <SID>WS:'y,'zs/\(\S\)\s\+/\1 /ge<CR>'yjma'zk:call AlignMaps#CharJoiner(",")<cr>:silent 'y,'zg/,/call AlignMaps#FixMultiDec()<CR>'z:exe "norm \<Plug>AM_adec"<cr><SID>WE
map <silent> <script> <Plug>AM_a< <SID>WS:AlignCtrl mIp1P1=l << >><CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_a= <SID>WS:AlignCtrl mIp1P1=l<CR>:AlignCtrl g :=<CR>:'a,'zAlign :\==<CR><SID>WE
map <silent> <script> <Plug>AM_abox <SID>WS:let g:alignmaps_iws=substitute(getline("'a"),'^\(\s*\).*$','\1','e')<CR>:'a,'z-1s/^\s\+//e<CR>:'a,'z-1s/^.*$/@&@/<CR>:AlignCtrl m=p01P0w @<CR>:'a,.Align<CR>:'a,'z-1s/@/ * /<CR>:'a,'z-1s/@$/*/<CR>'aYP:s/./*/g<CR>0r/'zkYp:s/./*/g<CR>0r A/<Esc>:exe "'a-1,'z-1s/^/".g:alignmaps_iws."/e"<CR><SID>WE
map <silent> <script> <Plug>AM_acom <SID>WS:'a,.s/\/[*/]\/\=/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:'y,'zs/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(2)<CR>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_adcom <SID>WS:'a,.v/^\s*\/[/*]/s/\/[*/]\*\=/@&@/e<CR>:'a,.v/^\s*\/[/*]/s/\*\//@&/e<CR>:'y,'zv/^\s*\/[/*]/s/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(3)<cr>:'y,'zv/^\s*\/[/*]/s/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_aocom <SID>WS:AlignPush<CR>:AlignCtrl g /[*/]<CR>:exe "norm \<Plug>AM_acom"<cr>:AlignPop<CR><SID>WE
map <silent> <script> <Plug>AM_ascom <SID>WS:'a,.s/\/[*/]/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:silent! 'a,.g/^\s*@\/[*/]/s/@//ge<CR>:AlignCtrl v ^\s*\/[*/]<CR>:AlignCtrl g \/[*/]<CR>'zk:call AlignMaps#StdAlign(2)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_adec <SID>WS:'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR>:'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR>:'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR>:'y,'zv/^\s*[*/]/s/^\(\s*\%(\K\k*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\)\([*(&]*\)\s*\([a-zA-Z0-9_()]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\=\s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR>:'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR>:'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR>:'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR>'yjma'zk:AlignCtrl v ^\s*[*/#]<CR>:call AlignMaps#StdAlign(1)<cr>:'y,'zv/^\s*[*/]/s/@ //ge<CR>:'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR>:'y,'zv/^#/s/# //e<CR>:'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR>:'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR>:'y,'zs/^[*]/ */e<CR><SID>WE
map <silent> <script> <Plug>AM_adef <SID>WS:AlignPush<CR>:AlignCtrl v ^\s*\(\/\*\<bar>\/\/\)<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/^\(\s*\)#\(\s\)*define\s*\(\I[a-zA-Z_0-9(),]*\)\s*\(.\{-}\)\($\<Bar>\/\*\)/#\1\2define @\3@\4@\5/e<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/\($\<Bar>\*\/\)/@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>'yjma'zk:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/ @//g<CR><SID>WE
map <silent> <script> <Plug>AM_afnc :<c-u>set lz<CR>:silent call AlignMaps#Afnc()<CR>:set nolz<CR>
map <silent> <script> <Plug>AM_aunum <SID>WS:'a,'zs/\%([0-9.]\)\s\+\zs\([-+.]\=\d\)/@\1/ge<CR>:'a,'zs/\(\(^\|\s\)\d\+\)\(\s\+\)@/\1@\3@/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [.@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(\.\)\(\s\+\)\([0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
map <silent> <script> <Plug>AM_aenum <SID>WS:'a,'zs/\%([0-9.]\)\s\+\([-+]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl mp0P0r<CR>:'a,'zAlign [,@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(,\)\(\s\+\)\([-0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
" ---------------------------------------------------------------------
" html table alignment {{{2
if !hasmapto('<Plug>AM_Htd')|map <unique> <Leader>Htd <Plug>AM_Htd|endif
map <silent> <script> <Plug>AM_Htd <SID>WS:'y,'zs%<[tT][rR]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]></[tT][rR]>%@&@%g<CR>'yjma'zk:AlignCtrl m=Ilp1P0 @<CR>:'a,.Align<CR>:'y,'zs/ @/@/<CR>:'y,'zs/@ <[tT][rR]>/<[tT][rR]>/ge<CR>:'y,'zs/@//ge<CR><SID>WE
" ---------------------------------------------------------------------
" character-based right-justified alignment maps {{{2
if !hasmapto('<Plug>AM_T|')|map <unique> <Leader>T| <Plug>AM_T||endif
if !hasmapto('<Plug>AM_T#') |map <unique> <Leader>T# <Plug>AM_T#|endif
if !hasmapto('<Plug>AM_T,') |map <unique> <Leader>T, <Plug>AM_T,o|endif
if !hasmapto('<Plug>AM_Ts,') |map <unique> <Leader>Ts, <Plug>AM_Ts,|endif
if !hasmapto('<Plug>AM_T:') |map <unique> <Leader>T: <Plug>AM_T:|endif
if !hasmapto('<Plug>AM_T;') |map <unique> <Leader>T; <Plug>AM_T;|endif
if !hasmapto('<Plug>AM_T<') |map <unique> <Leader>T< <Plug>AM_T<|endif
if !hasmapto('<Plug>AM_T=') |map <unique> <Leader>T= <Plug>AM_T=|endif
if !hasmapto('<Plug>AM_T?') |map <unique> <Leader>T? <Plug>AM_T?|endif
if !hasmapto('<Plug>AM_T@') |map <unique> <Leader>T@ <Plug>AM_T@|endif
if !hasmapto('<Plug>AM_Tab') |map <unique> <Leader>Tab <Plug>AM_Tab|endif
if !hasmapto('<Plug>AM_Tsp') |map <unique> <Leader>Tsp <Plug>AM_Tsp|endif
if !hasmapto('<Plug>AM_T~') |map <unique> <Leader>T~ <Plug>AM_T~|endif
map <silent> <script> <Plug>AM_T| <SID>WS:AlignCtrl mIp0P0=r <Bar><CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_T# <SID>WS:AlignCtrl mIp0P0=r #<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_T, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_Ts, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR>:'a,.s/\(\s*\),/,\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_T: <SID>WS:AlignCtrl mIp1P1=r :<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_T; <SID>WS:AlignCtrl mIp0P0=r ;<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_T< <SID>WS:AlignCtrl mIp0P0=r <<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_T= <SID>WS:'a,'z-1s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'z-1s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'z-1s/; */;@/e<CR>:'a,'z-1s/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'z-1s/!=/\x="!\<Char-0xff>"/ge<CR>:AlignCtrl mIp1P1=r = @<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s/; *@/;/e<CR>:'a,'z-1s/; *$/;/e<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-1s/\xff/=/ge<CR><SID>WE:exe "norm <Plug>acom"
map <silent> <script> <Plug>AM_T? <SID>WS:AlignCtrl mIp0P0=r ?<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_T@ <SID>WS:AlignCtrl mIp0P0=r @<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_Tab <SID>WS:'a,.s/^\(\t*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\t','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_Tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_T~ <SID>WS:AlignCtrl mIp0P0=r ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
" ---------------------------------------------------------------------
" character-based left-justified alignment maps {{{2
if !hasmapto('<Plug>AM_t|') |map <unique> <Leader>t| <Plug>AM_t||endif
if !hasmapto('<Plug>AM_t#') |map <unique> <Leader>t# <Plug>AM_t#|endif
if !hasmapto('<Plug>AM_t,') |map <unique> <Leader>t, <Plug>AM_t,|endif
if !hasmapto('<Plug>AM_ts,') |map <unique> <Leader>ts, <Plug>AM_ts,|endif
if !hasmapto('<Plug>AM_t:') |map <unique> <Leader>t: <Plug>AM_t:|endif
if !hasmapto('<Plug>AM_t;') |map <unique> <Leader>t; <Plug>AM_t;|endif
if !hasmapto('<Plug>AM_t<') |map <unique> <Leader>t< <Plug>AM_t<|endif
if !hasmapto('<Plug>AM_t=') |map <unique> <Leader>t= <Plug>AM_t=|endif
if !hasmapto('<Plug>AM_w=') |map <unique> <Leader>w= <Plug>AM_w=|endif
if !hasmapto('<Plug>AM_t?') |map <unique> <Leader>t? <Plug>AM_t?|endif
if !hasmapto('<Plug>AM_t~') |map <unique> <Leader>t~ <Plug>AM_t~|endif
if !hasmapto('<Plug>AM_t@') |map <unique> <Leader>t@ <Plug>AM_t@|endif
if !hasmapto('<Plug>AM_m=') |map <unique> <Leader>m= <Plug>AM_m=|endif
if !hasmapto('<Plug>AM_tab') |map <unique> <Leader>tab <Plug>AM_tab|endif
if !hasmapto('<Plug>AM_tml') |map <unique> <Leader>tml <Plug>AM_tml|endif
if !hasmapto('<Plug>AM_tsp') |map <unique> <Leader>tsp <Plug>AM_tsp|endif
if !hasmapto('<Plug>AM_tsq') |map <unique> <Leader>tsq <Plug>AM_tsq|endif
if !hasmapto('<Plug>AM_tt') |map <unique> <Leader>tt <Plug>AM_tt|endif
map <silent> <script> <Plug>AM_t| <SID>WS:AlignCtrl mIp0P0=l <Bar><CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_t# <SID>WS:AlignCtrl mIp0P0=l #<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_t, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR>:'a,.s/\(\s*\),/,\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t: <SID>WS:AlignCtrl mIp1P1=l :<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_t; <SID>WS:AlignCtrl mIp0P1=l ;<CR>:'a,.Align<CR>:'y,'zs/\( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t< <SID>WS:AlignCtrl mIp0P0=l <<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_t= <SID>WS:call AlignMaps#Equals()<CR><SID>WE
map <silent> <script> <Plug>AM_w= <SID>WS:'a,'zg/=/s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zg/=/s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zg/=/s/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zg/=/s/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mWp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1g/=/Align<CR>:'a,'z-1g/=/s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1g/=/s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1g/=/s/\xff/=/ge<CR>:'y,'zg/=/s/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_t? <SID>WS:AlignCtrl mIp0P0=l ?<CR>:'a,.Align<CR>:.,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t~ <SID>WS:AlignCtrl mIp0P0=l ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t@ <SID>WS::call AlignMaps#StdAlign(1)<cr>:<SID>WE
map <silent> <script> <Plug>AM_m= <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0xff>\<Char-0xff>"/ge<CR>:'a,'zs/!=/\="!\<Char-0xff>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-s/%\ze[^=]/ @%@ /e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/\xff/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_tab <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0xff>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0xff>"<bar>else<bar>exe "AlignCtrl mI=l \<Char-0xff>"<bar>endif<CR>:'a,.Align<CR>:exe "'y+1,'z-1s/\<Char-0xff>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE
map <silent> <script> <Plug>AM_tml <SID>WS:AlignCtrl mWp1P0=l \\\@<!\\\s*$<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_tsq <SID>WS:'a,.AlignReplaceQuotedSpaces<CR>:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).substitute(submatch(2),'\s\+','@','g')/<CR>:AlignCtrl mIp0P0=l @<CR>:'a,.Align<CR>:'y+1,'z-1s/[%@]/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_tt <SID>WS:AlignCtrl mIp1P1=l \\\@<!& \\\\<CR>:'a,.Align<CR><SID>WE
" =====================================================================
" Menu Support: {{{1
" ma ..move.. use menu
" v V or ctrl-v ..move.. use menu
if has("menu") && has("gui_running") && &go =~ 'm' && !exists("s:firstmenu")
let s:firstmenu= 1
if !exists("g:DrChipTopLvlMenu")
let g:DrChipTopLvlMenu= "DrChip."
endif
if g:DrChipTopLvlMenu != ""
let s:mapleader = exists("g:mapleader")? g:mapleader : '\'
let s:emapleader= escape(s:mapleader,'\ ')
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.<<\ and\ >><tab>'.s:emapleader.'a< '.s:mapleader.'a<'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ =<tab>'.s:emapleader.'t= '.s:mapleader.'t='
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ :=<tab>'.s:emapleader.'a= '.s:mapleader.'a='
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Backslashes<tab>'.s:emapleader.'tml '.s:mapleader.'tml'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Breakup\ Comma\ Declarations<tab>'.s:emapleader.'a, '.s:mapleader.'a,'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.C\ Comment\ Box<tab>'.s:emapleader.'abox '.s:mapleader.'abox'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas<tab>'.s:emapleader.'t, '.s:mapleader.'t,'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas<tab>'.s:emapleader.'ts, '.s:mapleader.'ts,'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas\ With\ Strings<tab>'.s:emapleader.'tsq '.s:mapleader.'tsq'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments<tab>'.s:emapleader.'acom '.s:mapleader.'acom'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments\ Only<tab>'.s:emapleader.'aocom '.s:mapleader.'aocom'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declaration\ Comments<tab>'.s:emapleader.'adcom '.s:mapleader.'adcom'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declarations<tab>'.s:emapleader.'adec '.s:mapleader.'adec'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Definitions<tab>'.s:emapleader.'adef '.s:mapleader.'adef'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Function\ Header<tab>'.s:emapleader.'afnc '.s:mapleader.'afnc'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Html\ Tables<tab>'.s:emapleader.'Htd '.s:mapleader.'Htd'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.(\.\.\.)?\.\.\.\ :\ \.\.\.<tab>'.s:emapleader.'a? '.s:mapleader.'a?'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers<tab>'.s:emapleader.'anum '.s:mapleader.'anum'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (American-Style)<tab>'.s:emapleader.'aunum <Leader>aunum '.s:mapleader.'aunum <Leader>aunum'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (Euro-Style)<tab>'.s:emapleader.'aenum '.s:mapleader.'aenum'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Left\ Justified)<tab>'.s:emapleader.'tsp '.s:mapleader.'tsp'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Right\ Justified)<tab>'.s:emapleader.'Tsp '.s:mapleader.'Tsp'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Statements\ With\ Percent\ Style\ Comments<tab>'.s:emapleader.'m= '.s:mapleader.'m='
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ <<tab>'.s:emapleader.'t< '.s:mapleader.'t<'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ \|<tab>'.s:emapleader.'t\| '.s:mapleader.'t|'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ @<tab>'.s:emapleader.'t@ '.s:mapleader.'t@'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ #<tab>'.s:emapleader.'t# '.s:mapleader.'t#'
exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Tabs<tab>'.s:emapleader.'tab '.s:mapleader.'tab'
unlet s:mapleader
unlet s:emapleader
endif
endif
" =====================================================================
" Restore: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ==============================================================================
" Modelines: {{{1
" vim: ts=4 nowrap fdm=marker

View File

@ -1,8 +1,8 @@
" -*- vim -*-
" FILE: "C:\Documents and Settings\William Lee\vimfiles\plugin\DirDiff.vim" {{{
" LAST MODIFICATION: "Wed, 22 Feb 2006 22:31:59 Central Standard Time"
" FILE: "/home/wlee/.vim/plugin/DirDiff.vim" {{{
" LAST MODIFICATION: "Mon, 20 Oct 2008 09:04:59 -0500 (wlee)"
" HEADER MAINTAINED BY: N/A
" VERSION: 1.1.1
" VERSION: 1.1.2
" (C) 2001-2006 by William Lee, <wl1012@yahoo.com>
" }}}
@ -71,9 +71,6 @@
" You can set the following DirDiff variables. You can add the following
" "let" lines in your .vimrc file.
"
" Sets diff command:
" let g:DirDiffCommand = $VIMRUNTIME . "diff"
"
" Sets default exclude pattern:
" let g:DirDiffExcludes = "CVS,*.class,*.exe,.*.swp"
"
@ -153,7 +150,9 @@
" Salman Halim, Yosuke Kimura, and others for their suggestions
"
" HISTORY:
" 1.1.1 - Added support for custom diff-command
" 1.1.2 - Applied the patch to 1.1.0 instead of 1.0.2. Please do not use
" 1.1.1
" 1.1.1 - Make it work with filename with spaces. (Thanks to Atte Kojo)
" 1.1.0 - Added support for i18n (tested on a French version for now only).
" Can dynamically figure out the diff strings output by diff.
" 1.0.2 - Fixed a small typo bug in the quit function.
@ -231,10 +230,6 @@ map <unique> <script> <Plug>DirDiffQuit :call <SID>DirDiffQuit()<CR>
" " ignore white space in diff
" let g:DirDiffAddArgs = "-w"
"
" You can set the diff command. Defaults to 'diff'
if !exists("g:DirDiffCommand")
let g:DirDiffCommand = "diff"
endif
" You can set the pattern that diff excludes. Defaults to the CVS directory
if !exists("g:DirDiffExcludes")
let g:DirDiffExcludes = ""
@ -358,7 +353,7 @@ function! <SID>DirDiff(srcA, srcB)
let DiffBuffer = tempname()
" We first write to that file
" Constructs the command line
let cmd = "!".g:DirDiffCommand
let cmd = "!diff"
let cmdarg = " -r --brief"
" If variable is set, we ignore the case
@ -540,7 +535,7 @@ function! <SID>DirDiffOpen()
endif
split
wincmd k
silent exec "edit ".fileToOpen
silent exec "edit ".fnameescape(fileToOpen)
" Fool the window saying that this is diff
diffthis
wincmd j
@ -551,8 +546,8 @@ function! <SID>DirDiffOpen()
"Open the diff windows
split
wincmd k
silent exec "edit ".fileB
silent exec "vert diffsplit ".fileA
silent exec "edit ".fnameescape(fileB)
silent exec "vert diffsplit ".fnameescape(fileA)
" Go back to the diff window
wincmd j
" Resize the window

View File

@ -2,8 +2,8 @@
" save/restore mark position
" save/restore selected user maps
" Author: Charles E. Campbell, Jr.
" Version: 17
" Date: Sep 04, 2007
" Version: 18b ASTRO-ONLY
" Date: Aug 27, 2008
"
" Saving Restoring Destroying Marks: {{{1
" call SaveMark(markname) let savemark= SaveMark(markname)
@ -28,19 +28,21 @@
" believe, and shudder. But do you want to know, vain man, that
" faith apart from works is dead? (James 2:19,20 WEB)
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_cecutil")
finish
endif
let g:loaded_cecutil = "v17"
let g:loaded_cecutil = "v18b"
let s:keepcpo = &cpo
set cpo&vim
"DechoVarOn
"DechoTabOn
" -----------------------
" =======================
" Public Interface: {{{1
" -----------------------
" =======================
" ---------------------------------------------------------------------
" Map Interface: {{{2
if !hasmapto('<Plug>SaveWinPosn')
map <unique> <Leader>swp <Plug>SaveWinPosn
@ -51,6 +53,7 @@ endif
nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR>
nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR>
" ---------------------------------------------------------------------
" Command Interface: {{{2
com! -bar -nargs=0 SWP call SaveWinPosn()
com! -bar -nargs=0 RWP call RestoreWinPosn()
@ -64,8 +67,12 @@ else
let s:modifier= "sil keepj "
endif
" ===============
" Functions: {{{1
" ===============
" ---------------------------------------------------------------------
" SaveWinPosn: {{{1
" SaveWinPosn: {{{2
" let winposn= SaveWinPosn() will save window position in winposn variable
" call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn}
" let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done)
@ -75,10 +82,10 @@ fun! SaveWinPosn(...)
" call Dfunc("SaveWinPosn : empty buffer")
return ""
endif
let so_keep = &so
let siso_keep = &siso
let ss_keep = &ss
set so=0 siso=0 ss=0
let so_keep = &l:so
let siso_keep = &l:siso
let ss_keep = &l:ss
setlocal so=0 siso=0 ss=0
let swline = line(".")
let swcol = col(".")
@ -107,9 +114,9 @@ fun! SaveWinPosn(...)
let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
endif
let &so = so_keep
let &siso = siso_keep
let &ss = ss_keep
let &l:so = so_keep
let &l:siso = siso_keep
let &l:ss = ss_keep
" if exists("b:cecutil_iwinposn") " Decho
" call Decho("b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]")
@ -121,7 +128,7 @@ fun! SaveWinPosn(...)
endfun
" ---------------------------------------------------------------------
" RestoreWinPosn: {{{1
" RestoreWinPosn: {{{2
fun! RestoreWinPosn(...)
" call Dfunc("RestoreWinPosn() a:0=".a:0)
" call Decho("getline(1)<".getline(1).">")
@ -130,10 +137,10 @@ fun! RestoreWinPosn(...)
" call Dfunc("RestoreWinPosn : empty buffer")
return ""
endif
let so_keep = &so
let siso_keep = &siso
let ss_keep = &ss
set so=0 siso=0 ss=0
let so_keep = &l:so
let siso_keep = &l:siso
let ss_keep = &l:ss
setlocal so=0 siso=0 ss=0
if a:0 == 0 || a:1 == ""
" use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
@ -184,23 +191,25 @@ fun! RestoreWinPosn(...)
endif
endif
" seems to be something odd: vertical motions after RWP
" cause jump to first column. Following fixes that
if wincol() > 1
" Seems to be something odd: vertical motions after RWP
" cause jump to first column. The following fixes that.
" Note: was using wincol()>1, but with signs, a cursor
" at column 1 yields wincol()==3. Beeping ensued.
if virtcol('.') > 1
silent norm! hl
elseif virtcol(".") < virtcol("$")
silent norm! lh
endif
let &so = so_keep
let &siso = siso_keep
let &ss = ss_keep
let &l:so = so_keep
let &l:siso = siso_keep
let &l:ss = ss_keep
" call Dret("RestoreWinPosn")
endfun
" ---------------------------------------------------------------------
" GoWinbufnr: go to window holding given buffer (by number) {{{1
" GoWinbufnr: go to window holding given buffer (by number) {{{2
" Prefers current window; if its buffer number doesn't match,
" then will try from topleft to bottom right
fun! GoWinbufnr(bufnum)
@ -219,7 +228,7 @@ fun! GoWinbufnr(bufnum)
endfun
" ---------------------------------------------------------------------
" SaveMark: sets up a string saving a mark position. {{{1
" SaveMark: sets up a string saving a mark position. {{{2
" For example, SaveMark("a")
" Also sets up a global variable, g:savemark_{markname}
fun! SaveMark(markname)
@ -252,7 +261,7 @@ fun! SaveMark(markname)
endfun
" ---------------------------------------------------------------------
" RestoreMark: {{{1
" RestoreMark: {{{2
" call RestoreMark("a") -or- call RestoreMark(savemark)
fun! RestoreMark(markname)
" call Dfunc("RestoreMark(markname<".a:markname.">)")
@ -294,7 +303,7 @@ fun! RestoreMark(markname)
endfun
" ---------------------------------------------------------------------
" DestroyMark: {{{1
" DestroyMark: {{{2
" call DestroyMark("a") -- destroys mark
fun! DestroyMark(markname)
" call Dfunc("DestroyMark(markname<".a:markname.">)")
@ -329,7 +338,7 @@ fun! DestroyMark(markname)
endfun
" ---------------------------------------------------------------------
" QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{1
" QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{2
" However, <q-args> doesn't split at all, so this one returns a list
" with splits at all whitespace (only!), plus a leading length-of-list.
" The resulting list: qarglist[0] corresponds to a:0
@ -344,7 +353,7 @@ fun! QArgSplitter(qarg)
endfun
" ---------------------------------------------------------------------
" ListWinPosn:
" ListWinPosn: {{{2
"fun! ListWinPosn() " Decho
" if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho
" call Decho("nothing on SWP stack") " Decho
@ -363,14 +372,19 @@ endfun
"com! -nargs=0 LWP call ListWinPosn() " Decho
" ---------------------------------------------------------------------
" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{1
" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{2
" which can be used to restore user maps later with
" call RestoreUserMaps()
"
" mapmode - see :help maparg for its list
" mapmode - see :help maparg for details (n v o i c l "")
" ex. "n" = Normal
" If the first letter is u, then unmapping will be done
" ex. "un" = Normal + unmapping
" The letters "b" and "u" are optional prefixes;
" The "u" means that the map will also be unmapped
" The "b" means that the map has a <buffer> qualifier
" ex. "un" = Normal + unmapping
" ex. "bn" = Normal + <buffer>
" ex. "bun" = Normal + <buffer> + unmapping
" ex. "ubn" = Normal + <buffer> + unmapping
" maplead - see mapchx
" mapchx - "<something>" handled as a single map item.
" ex. "<left>"
@ -395,60 +409,70 @@ fun! SaveUserMaps(mapmode,maplead,mapchx,suffix)
" set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u")
" if 0, save only
if a:mapmode =~ '^u'
let dounmap= 1
let mapmode= strpart(a:mapmode,1)
else
let dounmap= 0
let mapmode= a:mapmode
endif
let mapmode = a:mapmode
let dounmap = 0
let dobuffer = ""
while mapmode =~ '^[bu]'
if mapmode =~ '^u'
let dounmap= 1
let mapmode= strpart(a:mapmode,1)
elseif mapmode =~ '^b'
let dobuffer= "<buffer> "
let mapmode= strpart(a:mapmode,1)
endif
endwhile
" call Decho("dounmap=".dounmap." dobuffer<".dobuffer.">")
" save single map :...something...
if strpart(a:mapchx,0,1) == ':'
" call Decho("save single map :...something...")
let amap= strpart(a:mapchx,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let amap = a:maplead.amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:silent! ".mapmode."unmap ".amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:silent! ".mapmode."unmap ".dobuffer.amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".amap." ".maprhs
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".dobuffer.amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
exe "silent! ".mapmode."unmap ".dobuffer.amap
endif
" save single map <something>
elseif strpart(a:mapchx,0,1) == '<'
" call Decho("save single map <something>")
let amap = a:mapchx
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
" call Decho("amap[[".amap."]]")
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".dobuffer.amap
if maparg(a:mapchx,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".dobuffer.maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
exe "silent! ".mapmode."unmap ".dobuffer.amap
endif
" save multiple maps
else
" call Decho("save multiple maps")
let i= 1
while i <= strlen(a:mapchx)
let amap= a:maplead.strpart(a:mapchx,i-1,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".dobuffer.amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".dobuffer.maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
exe "silent! ".mapmode."unmap ".dobuffer.amap
endif
let i= i + 1
endwhile
@ -457,7 +481,7 @@ fun! SaveUserMaps(mapmode,maplead,mapchx,suffix)
endfun
" ---------------------------------------------------------------------
" RestoreUserMaps: {{{1
" RestoreUserMaps: {{{2
" Used to restore user maps saved by SaveUserMaps()
fun! RestoreUserMaps(suffix)
" call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)")
@ -472,11 +496,13 @@ fun! RestoreUserMaps(suffix)
" call Dret("RestoreUserMaps")
endfun
" ---------------------------------------------------------------------
" ==============
" Restore: {{{1
" ==============
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" ================
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker

View File

@ -16,19 +16,16 @@
" But be doers of the Word, and not only hearers, deluding your own selves {{{1
" (James 1:22 RSV)
" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_netrwPlugin")
finish
endif
let g:loaded_netrwPlugin = "v133"
let s:keepcpo = &cpo
if v:version < 700
echohl WarningMsg | echo "***netrw*** you need vim version 7.0 for this version of netrw" | echohl None
let g:loaded_netrwPlugin = "v134"
if v:version < 702
echohl WarningMsg | echo "***netrw*** you need vim version 7.2 for this version of netrw" | echohl None
finish
endif
let s:keepcpo= &cpo
let s:keepcpo = &cpo
set cpo&vim
" ---------------------------------------------------------------------

View File

@ -22,7 +22,7 @@ syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify
syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" contains=netrwDateSep skipwhite nextgroup=netrwTime
syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify
syn match netrwExe "\%(\S\+ \)*\S\+\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify
syn match netrwTreeBar "^\%(| \)*" contains=netrwTreeBarSpace nextgroup=@netrwTreeGroup
syn match netrwTreeBar "^\%([-+|] \)*" contains=netrwTreeBarSpace nextgroup=@netrwTreeGroup
syn match netrwTreeBarSpace " " contained
syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained