add vim conf files
[arrow.git] / conf_slk120 / vim / _vim / plugin / vtreeexplorer.vim
blobf722854557224d44a76560225e8061b2718ca1db
1 "" File:        vtreeexplorer.vim
2 "" Description: tree-like file system explorer for vim
3 "" Version:     $Revision: 1.1.1.1 $ $Date: 2006/03/31 18:55:13 $
4 "" Author:      TS Urban (thomas.scott.urban@HORMELgmail.net)
5 ""              (remove the source of SPAM from my email first)
6 ""
7 "" Instructions:
8 ""   1 - source this file or put in your plugin directory
9 ""   2 - :VTreeExlorer or :VSTreeExplore
10 ""   3 - help at top of screen
11 ""   4 - this script comes with a help text that integrates with the vim help
12 ""       system, put vtreeexplorer.txt in your ~/.vim/doc dir, then do
13 ""         :helptags ~/.vim/doc
15 "" Global Configuration Variables:
16 ""  treeExplVertical : split vertically when starting with VSTreeExplore
17 ""  treeExplWinSize  : window size (width or height) when doing VSTreeExplore
18 ""  treeExplHidden   : set to have explorer start with hidden files shown
19 ""  treeExplDirSort  : start explorer with desired directory sorting:
20 ""    0 : no directory sorting
21 ""    1 : directories sorting first
22 ""   -1 : directories sorting last
23 ""  treeExplIndent   : width of tree indentation in spaces (min 3, max 8)
25 "" Todo:
26 ""   - global option for path separator
27 ""   - merge in patches for winmanager
28 ""   - +/- keymappings, etc
29 ""   - recursively collapse binding/function
31 "" prevent multiple loading unless developing with g:treeExplDebug
32 if exists("vloaded_tree_explorer") && !exists("g:treeExplDebug")
33         finish
34 endif
35 let vloaded_tree_explorer=1
37 let s:cpo_save = &cpo
38 set cpo&vim
40 "" create commands
41 command! -n=? -complete=dir VTreeExplore :call s:TreeExplorer(0, '<a>')
42 command! -n=? -complete=dir VSTreeExplore :call s:TreeExplorer(1, '<a>')
44 "" support sessions
45 autocmd BufNewFile TreeExplorer VTreeExplore
47 "" create a string of chr cnt long - emulate vim7 repeat function
48 function! s:MyRepeat(chr, cnt) " <<<
49         let sret = ""
50         let lcnt = a:cnt
51         while lcnt > 0
52                 let sret = sret . a:chr
53                 let lcnt = lcnt - 1
54         endwhile
55         return sret
56 endf " >>>
58 "" TreeExplorer() - set up explorer window
59 function! s:TreeExplorer(split, start) " <<<
61         " dir to start in from arg, buff dir, or pwd
62         let fname = (a:start != "") ? a:start : expand ("%:p:h")
63         let fname = (fname != "") ? fname : getcwd ()
65         " construct command to open window
66         if a:split || &modified
67                 " if starting with split, get split parameters from globals
68                 let splitMode = (exists("g:treeExplVertical")) ? "vertical " : ""
69                 let splitSize = (exists("g:treeExplWinSize")) ? g:treeExplWinSize : 20
70                 let cmd = splitMode . splitSize . "new TreeExplorer"
71         else
72                 let cmd = "e TreeExplorer"
73         endif
74         silent execute cmd
76         "" chars to escape in file/dir names - TODO '+' ?
77         let w:escape_chars =  " `|\"~'#"
79         " win specific vars from globals if they exist
80         let w:hidden_files = (exists("g:treeExplHidden")) ? 1 : 0
81         let w:dirsort = (exists("g:treeExplDirSort")) ? g:treeExplDirSort : 0
82         if w:dirsort < -1 || w:dirsort > 1
83                 let w:dirsort = 0
84                 " TODO - needed?
85                 let w:escape_chars = w:escape_chars . '+'
86         endif
88         " tree visual widget configuration, width limited to range [3,16]
89         let w:tree_wid_ind = (exists("g:treeExplIndent")) ? g:treeExplIndent : 3
90         let w:tree_wid_ind = (w:tree_wid_ind < 3) ?  3 : w:tree_wid_ind
91         let w:tree_wid_ind = (w:tree_wid_ind > 8) ? 16 : w:tree_wid_ind
93         let bar_char = '|'
94         let dsh_char = '-'
95         let grv_char = '`'
96         let spc_char = ' '
98         let w:tree_par_wid = bar_char . s:MyRepeat (spc_char, w:tree_wid_ind - 2) . spc_char
99         let w:tree_dir_wid = bar_char . s:MyRepeat (dsh_char, w:tree_wid_ind - 2) . spc_char
100         let w:tree_end_wid = grv_char . s:MyRepeat (dsh_char, w:tree_wid_ind - 2) . spc_char
101         let w:tree_spc_wid = s:MyRepeat (spc_char, w:tree_wid_ind)
103         " init help to short version
104         let w:helplines = 1
106         " throwaway buffer options
107         setlocal noswapfile
108         setlocal buftype=nowrite
109         setlocal bufhidden=delete " d
110         setlocal nowrap
111         iabc <buffer>
113         " setup folding for markers that will be inserted
114         setlocal foldmethod=marker
115         setlocal foldtext=substitute(getline(v:foldstart),'.{{{.*','','')
116         setlocal foldlevel=1
118   " syntax highlighting
119   if has("syntax") && exists("g:syntax_on") && !has("syntax_items")
120     syn match treeHlp  #^" .*#
121     syn match treeDir  "^\.\. (up a directory)$"
123                 syn match treeFld  "{{{"
124                 syn match treeFld  "}}}"
126                 execute "syn match treePrt  #" . w:tree_par_wid . "#"
127                 execute "syn match treePrt  #" . w:tree_dir_wid . "#"
128                 execute "syn match treePrt  #" . w:tree_end_wid . "#"
130                 syn match treeLnk  #[^-| `].* -> # contains=treeFld
131     syn match treeDir  #[^-| `].*/\([ {}]\{4\}\)*$# contains=treeFld,treeLnk
132     syn match treeCWD  #^/.*$# contains=treeFld
134                 hi def link treePrt Normal
135                 hi def link treeFld Ignore
136     hi def link treeHlp Special
137     hi def link treeDir Directory
138     hi def link treeCWD Statement
139                 hi def link treeLnk Title
140   endif
142         " for line continuation
143   let cpo_save1 = &cpo
144   set cpo&vim
146         " set up mappings and commands for this buffer
147   nnoremap <buffer> <cr> :call <SID>Activate()<cr>
148   nnoremap <buffer> o    :call <SID>Activate()<cr>
149         nnoremap <buffer> X    :call <SID>RecursiveExpand()<cr>
150         nnoremap <buffer> E    :call <SID>OpenExplorer()<cr>
151   nnoremap <buffer> C    :call <SID>ChangeTop()<cr>
152   nnoremap <buffer> H    :call <SID>InitWithDir($HOME)<cr>
153         nnoremap <buffer> u    :call <SID>ChdirUp()<cr>
154         nnoremap <buffer> p    :call <SID>MoveParent()<cr>
155         nnoremap <buffer> r    :call <SID>RefreshDir()<cr>
156   nnoremap <buffer> R    :call <SID>InitWithDir("")<cr>
157         nnoremap <buffer> S    :call <SID>StartShell()<cr>
158         nnoremap <buffer> D    :call <SID>ToggleDirSort()<cr>
159         nnoremap <buffer> a    :call <SID>ToggleHiddenFiles()<cr>
160   nnoremap <buffer> ?    :call <SID>ToggleHelp()<cr>
161         nnoremap <buffer> <2-leftmouse> :call <SID>Activate()<cr>
163         command! -buffer -complete=dir -nargs=1 CD :call s:TreeCD('<a>')
164         command! -buffer -range -nargs=0 Yank :<line1>,<line2>y |
165                                 \ let @" = substitute (@", ' [{}]\{3\}', "", "g")
167   let &cpo = cpo_save1 " restore
169         call s:InitWithDir(fname) " load fname dir
170 endfunction " >>>
172 "" TreeCD() - change to dir from cmdline arg
173 function! s:TreeCD(dir) " <<<
174         if isdirectory (a:dir)
175                 call s:InitWithDir (a:dir)
176         else
177                 echo "can not change to directory: " . a:dir
178         endif
179 endfunction " >>>
181 "" InitWithDir() - reload tree with dir
182 function! s:InitWithDir(dir) " <<<
183         if a:dir != ""
184                 execute "lcd " . escape (a:dir, w:escape_chars)
185         endif
186         let cwd = getcwd ()
188         if has("unix") == 0 
189                 let cwd = substitute (cwd, '\\', '/', "g")
190                 let is_root = (cwd =~ '^[A-Z]:/$') ? 1 : 0
191         else
192                 let is_root = (cwd == "/") ? 1 : 0
193         endif
195         let cwd = substitute (cwd, '/*$', '/', "")
197         " clear buffer
198         setlocal modifiable | silent! normal ggdG
199         setlocal nomodifiable
201         "insert header
202         call s:AddHeader()
203         normal G
205         let save_f=@f
207         "insert parent link unless we're at / for unix or X:\ for dos
208         if is_root == 0
209                 let @f=".. (up a directory)"
210         endif
211         let @f=@f . "\n" . cwd  . "\n\n"
213         setlocal modifiable | silent put f | setlocal nomodifiable
215         normal Gk
217         call s:ReadDir (line("."), cwd) " read dir
219         let @f=save_f
220 endfunction " >>>
222 "" ReadDir() -  read dir after current line with tree pieces and foldmarkers
223 function! s:ReadDir(lpn,dir) " <<<
224         let olddir = getcwd ()
226         let lps = getline (a:lpn)
228         if a:dir == ""
229                 let dir = GetAbsPath2 (lpn, 0)
230                 if w:firstdirline ! = lpn
231                         echo "ERROR"
232                         return
233                 endif
234         else
235                 let dir = a:dir
236         endif
238         " TODO - error when dir no longer exists
239         try
240                 execute "lcd " . escape (dir, w:escape_chars)
241         catch
242                 echo "ERROR: changing to directory: " . dir
243                 return
244         endtry
246         """ THIS BLOCK DOESN' DO ANYTHING
247         " change dos path to look like unix path
248         "if has("unix") == 0 " TODO - so many dos/win variants, this seemed easier - maybe not correct (e.g. OS2, mac, etc)
249         "       let dir = substitute (dir, '\\', '/', "g")
250         "endif
251         "let dir = substitute (dir, '/\?$', '/', "")
252         """ THIS BLOCK DOESN' DO ANYTHING
253         
254         " get dir contents
255         if w:hidden_files == 1
256                 let dirlines = glob ('.*') . "\n" . glob ('*')
257         else
258                 let dirlines = glob ('*')
259         endif
261         " if empty, don't change line
262         if dirlines == ""
263                 return
264         endif
266         let treeprt = substitute (lps, '[^-| `].*', "", "")
267         let pdirprt = substitute (lps, '^[-| `]*', "", "")
268         let pdirprt = substitute (pdirprt, '[{} ]*$', "", "")
269         let foldprt = substitute (lps, '.*' . pdirprt, "", "")
271         " save states of registers for restoring
272         " @l is used for first line, last line, and if dir sorting is off
273         " @f and @d are used for file and dirs with dir sorting
274         let save_l = @l | let @l = ""
275         let save_d = @d | let @d = ""
276         let save_f = @f | let @f = ""
278         let @l = treeprt . pdirprt . ' {{{'
280         let treeprt = substitute (treeprt, w:tree_end_wid, w:tree_spc_wid, "")
281         let treeprt = substitute (treeprt, w:tree_dir_wid, w:tree_par_wid, "")
283         " parse dir contents by '/'
284         let dirlines = substitute (dirlines, "\n", '/', "g")
286         while strlen (dirlines) > 0
287                 let curdir = substitute (dirlines, '/.*', "", "")
288                 let dirlines = substitute (dirlines, '[^/]*/\?', "", "")
290                 if w:hidden_files == 1 && curdir =~ '^\.\.\?$'
291                         continue
292                 endif
294                 let linkedto = resolve (curdir)
295                 if linkedto != curdir
296                         let curdir = curdir . ' -> ' . linkedto
297                 endif
298                 if isdirectory (linkedto)
299                         let isdir = 1
300                         let curdir = curdir . '/'
301                 else
302                         let isdir = 0
303                 endif
305                 " escape leading characters confused with tree parts
306                 if curdir =~ '^[-| `]'
307                         let curdir = '\' . curdir
308                 endif
310                 if w:dirsort != 0
311                         if isdir == 1
312                                 let @d = @d . "\n" . treeprt . w:tree_dir_wid . curdir
313                         else
314                                 let @f = @f . "\n" . treeprt . w:tree_dir_wid . curdir
315                         endif
316                 else
317                         let @l = @l . "\n" . treeprt . w:tree_dir_wid . curdir
318                 endif
319         endwhile
321         if w:dirsort == 1
322                 let @l = @l .  @d . @f . "\n"
323         elseif w:dirsort == -1
324                 let @l = @l .  @f . @d . "\n"
325         else
326                 let @l = @l . "\n"
327         endif
329         exec (":" . a:lpn)
331         " TODO handle fold open v fold closed
332         setlocal modifiable
333         silent normal ddk
334         silent put l
335         setlocal nomodifiable
337         " make sure fold is open so we don't delete the whole thing
338         "if foldclosed (line (".")) != -1
339         if foldclosed (a:lpn) != -1
340                 foldopen
341         endif
343         normal! `]
345         " change last tree part to the final leaf marking, add final fold mark
346         let @l = getline(".")
347         let @l = substitute (@l, w:tree_dir_wid, w:tree_end_wid, "")
348         let @l = @l . foldprt . " }}}\n"
350         setlocal modifiable | silent normal dd
351         silent put! l | setlocal nomodifiable
353         " restore registers
354         let @l = save_l
355         let @d = save_d
356         let @f = save_f
358         exec (":" . a:lpn)
360         execute "lcd " . escape (olddir, w:escape_chars)
361 endfunction " >>>
363 "" ChdirUp() -  cd up (if possible)
364 function! s:ChdirUp() " <<<
365         let cwd = getcwd()
366         if cwd == "/" || cwd =~ '^[^/]..$'
367                 echo "already at top dir"
368         else
369                 call s:InitWithDir("..")
370         endif
371 endfunction " >>>
373 "" MoveParent() - move cursor to parent dir
374 function! s:MoveParent() " <<<
375         let ln = line(".")
376         call s:GetAbsPath2 (ln, 1)
377         if w:firstdirline != 0
378                 exec (":" . w:firstdirline)
379         else
380                 exec (":" . w:helplines)
381         endif
382 endfunction " >>>
384 "" ChangeTop() - change top dir to cursor dir
385 function! s:ChangeTop() " <<<
386         let ln = line(".")
387   let l = getline(ln)
389         " on current top or non-tree line?
390         if l !~ '^[| `]'
391                 return
392         endif
394         " parent dir
395         if l =~ '^\.\. '
396                 call s:ChdirUp()
397                 return
398         endif
400         let curfile = s:GetAbsPath2(ln, 0)
401         if curfile !~ '/$'
402                 let curfile = substitute (curfile, '[^/]*$', "", "")
403         endif
404         call s:InitWithDir (curfile)
405 endfunction " >>>
407 "" RecursiveExpand() - expand cursor dir recursively
408 function! s:RecursiveExpand() " <<<
409         echo "recursively expanding, this might take a while (CTRL-C to stop)"
411         let curfile = s:GetAbsPath2(line("."), 0)
413         if w:firstdirline == 0
414                 let init_ln = w:helplines
415                 let curfile = substitute (getline (init_ln), '[ {]*', "", "")
416         else
417                 let init_ln = w:firstdirline
418         endif
420         let init_ind = match (getline (init_ln), '[^-| `]') / w:tree_wid_ind
422         let curfile = substitute (curfile, '[^/]*$', "", "")
424         let l = getline (init_ln)
426         if l =~ ' {{{$'
427                 if foldclosed (init_ln) != -1
428                         foldopen
429                 endif
430         endif
432         if l !~ ' {{{$' " dir not open
433                 call s:ReadDir (init_ln, curfile)
435                 if getline (init_ln) !~ ' {{{$' " dir still not open (empty)
436                         echo "expansion done"
437                         return
438                 endif
439         endif
441         let ln = init_ln + 1
443         let l = getline (ln)
445         let match_str = '[^-| `]'
446         while init_ind < (match (l, '[^-| `]') / w:tree_wid_ind)
447                 let tl = l
448                 let tln = ln
449                 let ln = ln + 1
450                 let l = getline (ln)
452                 if tl =~ ' {{{$'
453                         if foldclosed (tln) != -1
454                                 foldopen
455                         endif
456                         continue
457                 endif
459                 " link or non dir
460                 if tl =~ ' -> ' || tl !~ '/[ }]*$'
461                         continue
462                 endif
464                 let curfile = s:GetAbsPath2(tln, 0)
466                 call s:ReadDir (tln, curfile)
468                 let l = getline (ln)
469         endwhile
471         exec (":" . init_ln)
472         echo "expansion done"
473 endfunction " >>>
475 "" OpenExplorer() - open file explorer on cursor dir
476 function! s:OpenExplorer() " <<<
477         let curfile = s:GetAbsPath2 (line ("."), 0)
479         if w:firstdirline == 0
480                 let curfile = getcwd ()
481         else
482                 " remove file name, if any
483                 let curfile = substitute (curfile, '[^/]*$', "", "")
484         endif
486         let curfile = escape (curfile, w:escape_chars)
488         let oldwin = winnr()
489         wincmd p
490         if oldwin == winnr() || &modified
491                 wincmd p
492                 exec ("new " . curfile)
493         else
494                 exec ("edit " . curfile)
495         endif
497 endfunction " >>>
499 "" Activate() - (un)fold read dirs, read unread dirs, open files, cd .. on ..
500 function! s:Activate() " <<<
501         let ln = line(".")
502   let l = getline(ln)
504         " parent dir, change to it
505   if l =~ '^\.\. (up a directory)$'
506                 call s:ChdirUp()
507     return
508   endif
510         " directory loaded, toggle folded state
511         if l =~ ' {{{$'
512                 if foldclosed(ln) == -1
513                         foldclose
514                 else
515                         foldopen
516                 endif
517                 return
518         endif
520         " on top, no folds, or not on tree
521         if l !~ '^[-| `]'
522                 return
523         endif
525         " get path of line
526         let curfile = s:GetAbsPath2 (ln, 0)
528         if curfile =~ '/$' " dir
529           call s:ReadDir (ln, curfile)
530                 return
531         else " file
532                 let f = escape (curfile, w:escape_chars)
533                 let oldwin = winnr()
534                 wincmd p
535                 if oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2)
536                         wincmd p
537                         exec ("new " . f)
538                 else
539                         exec ("edit " . f)
540                 endif
541         endif
542 endfunction " >>>
544 "" RefreshDir() - refresh current dir
545 function! s:RefreshDir() " <<<
546         let curfile = s:GetAbsPath2(line("."), 0)
548         let init_ln = w:firstdirline
550         " not in tree, or on path line or parent is top
551         if curfile == "" || init_ln == 0
552                 call s:InitWithDir("")
553                 return
554         endif
556         let save_l = @l
558         " remove file name, if any
559         let curfile = substitute (curfile, '[^/]*$', "", "")
561         let @l = getline (init_ln)
563         " if there is no fold, just do normal ReadDir, and return
564         if @l !~ ' {{{$'
565                 call s:ReadDir (init_ln, curfile)
566                 let @l = save_l
567                 return
568         endif
570         " TODO factor
572         if foldclosed(init_ln) == -1
573                 foldclose
574         endif
576         " remove one foldlevel from line
577         let @l = substitute (@l, ' {{{$', "", "")
579         exec (":" . init_ln)
581         setlocal modifiable
582         silent normal ddk
583         silent put l
584         setlocal nomodifiable
586         call s:ReadDir (init_ln, curfile)
588         let @l = save_l
589 endfunction " >>>
591 "" ToggleHiddenFiles() - toggle hidden files
592 function! s:ToggleHiddenFiles() " <<<
593         let w:hidden_files = w:hidden_files ? 0 : 1
594         let msg = w:hidden_files ? "on" : "off"
595         let msg = "hidden files now = " . msg
596         echo msg
597         call s:UpdateHeader ()
598         call s:RefreshDir()
599 endfunction " >>>
601 "" ToggleDirSort() - toggle dir sorting
602 function! s:ToggleDirSort() " <<<
603         if w:dirsort == 0
604                 let w:dirsort = 1
605                 let msg = "dirs first"
606         elseif w:dirsort > 0
607                 let w:dirsort = -1
608                 let msg = "dirs last"
609         else
610                 let w:dirsort = 0
611                 let msg = "off"
612         endif
613         let msg = "dirs sorting now = " . msg
614         echo msg
615         call s:UpdateHeader ()
616         call s:RefreshDir()
617 endfunction " >>>
619 "" StartShell() - start shell in cursor dir
620 function! s:StartShell() " <<<
621         let ln = line(".")
623         let curfile = s:GetAbsPath2 (ln, 1)
624         let prevdir = getcwd()
626         if w:firstdirline == 0
627                 let dir = prevdir
628         else
629                 let dir = substitute (curfile, '[^/]*$', "", "")
630         endif
632         execute "lcd " . escape (dir, w:escape_chars)
633         shell
634         execute "lcd " . escape (prevdir, w:escape_chars)
635 endfunction " >>>
637 "" GetAbsPath2() -  get absolute path at line ln, set w:firstdirline,
638 ""  - if ignore_current is 1, don't set line to current line when on a dir
639 function! s:GetAbsPath2(ln,ignore_current) " <<<
640         let lnum = a:ln
641         let l = getline(lnum)
643         let w:firstdirline = 0
645         " in case called from outside the tree
646         if l =~ '^[/".]' || l =~ '^$'
647                 return ""
648         endif
650         let wasdir = 0
652         " strip file
653         let curfile = substitute (l,'^[-| `]*',"","") " remove tree parts
654         let curfile = substitute (curfile,'[ {}]*$',"",'') " remove fold marks
655         "let curfile = substitute (curfile,'[*=@|]$',"","") " remove file class
657         " remove leading escape
658         let curfile = substitute (curfile,'^\\', "", "")
660         if curfile =~ '/$' && a:ignore_current == 0
661                 let wasdir = 1
662                 let w:firstdirline = lnum
663         endif
665         let curfile = substitute (curfile,' -> .*',"","") " remove link to
666         if wasdir == 1
667                 let curfile = substitute (curfile, '/\?$', '/', "")
668         endif
670         let indent = match(l,'[^-| `]') / w:tree_wid_ind
672         let dir = ""
673         while lnum > 0
674                 let lnum = lnum - 1
675                 let lp = getline(lnum)
676                 if lp =~ '^/'
677                         let sd = substitute (lp, '[ {]*$', "", "")
678                         let dir = sd . dir
679                         break
680                 endif
681                 if lp =~ ' {{{$'
682                         let lpindent = match(lp,'[^-| `]') / w:tree_wid_ind
683                         if lpindent < indent
684                                 if w:firstdirline == 0
685                                         let w:firstdirline = lnum
686                                 endif
687                                 let indent = indent - 1
688                                 let sd = substitute (lp, '^[-| `]*',"","") " rm tree parts
689                                 let sd = substitute (sd, '[ {}]*$', "", "") " rm foldmarks
690                                 let sd = substitute (sd, ' -> .*','/',"") " replace link to with /
692                                 " remove leading escape
693                                 let sd = substitute (sd,'^\\', "", "")
695                                 let dir = sd . dir
696                                 continue
697                         endif
698                 endif
699         endwhile
700         let curfile = dir . curfile
701         return curfile
702 endfunction " >>>
704 "" ToggleHelp() - toggle between long and short help
705 function! s:ToggleHelp() " <<<
706         let w:helplines = (w:helplines <= 4) ? 6 : 0
707         call s:UpdateHeader ()
708 endfunction " >>>
710 "" Determine the number of windows open to this buffer number.
711 "" Care of Yegappan Lakshman.  Thanks!
712 fun! s:BufInWindows(bnum) " <<<
713   let cnt = 0
714   let winnum = 1
715   while 1
716     let bufnum = winbufnr(winnum)
717     if bufnum < 0
718       break
719     endif
720     if bufnum == a:bnum
721       let cnt = cnt + 1
722     endif
723     let winnum = winnum + 1
724   endwhile
726   return cnt
727 endfunction " >>>
729 "" UpdateHeader() - update the header
730 function! s:UpdateHeader() " <<<
731         let oldRep=&report
732         set report=10000
733         normal! mt
735   " Remove old header
736   0
737         setlocal modifiable | silent! 1,/^" ?/ d _ | setlocal nomodifiable
739   call s:AddHeader()
741         " return to previous mark
742   0
743   if line("'t") != 0
744     normal! `t
745   endif
747   let &report=oldRep
748 endfunction " >>>
750 "" - AddHeader() -  add the header with help information
751 function! s:AddHeader() " <<<
752         if w:dirsort == 0
753                 let dt = "off)\n"
754         elseif w:dirsort == 1
755                 let dt = "dirs first)\n"
756         else
757                 let dt = "dirs last)\n"
758         endif
760         let save_f=@f
761         1
762         let ln = 3
763         if w:helplines > 4
764                 let ln=ln+1 | let @f=   "\" <ret> = same as 'o' below\n"
765                 let ln=ln+1 | let @f=@f."\" o     = (file) open in another window\n"
766                 let ln=ln+1 | let @f=@f."\" o     = (dir) toggle dir fold or load dir\n"
767                 let ln=ln+1 | let @f=@f."\" X     = recursive expand cursor dir\n"
768                 let ln=ln+1 | let @f=@f."\" E     = open Explorer on cursor dir\n"
769                 let ln=ln+1 | let @f=@f."\" C     = chdir top of tree to cursor dir\n"
770                 let ln=ln+1 | let @f=@f."\" H     = chdir top of tree to home dir\n"
771                 let ln=ln+1 | let @f=@f."\" u     = chdir top of tree to parent dir\n"
772                 let ln=ln+1 | let @f=@f."\" :CD d = chdir top of tree to dir <d>\n"
773                 let ln=ln+1 | let @f=@f."\" p     = move cursor to parent dir\n"
774                 let ln=ln+1 | let @f=@f."\" r     = refresh cursor dir\n"
775                 let ln=ln+1 | let @f=@f."\" R     = refresh top dir\n"
776                 let ln=ln+1 | let @f=@f."\" S     = start a shell in cursor dir\n"
777                 let ln=ln+1 | let @f=@f."\" :Yank = yank <range> lines withoug fold marks\n"
778                 let ln=ln+1 | let @f=@f."\" D     = toggle dir sort (now = " . dt
779                 let ln=ln+1 | let @f=@f."\" a     = toggle hidden files (now = "
780                                         \ . ((w:hidden_files) ? "on)\n" : "off)\n")
781                 let ln=ln+1 | let @f=@f."\" ?     = toggle long help\n"
782         else
783                 let ln=ln+1 | let @f="\" ? : toggle long help\n"
784         endif
785         let w:helplines = ln
787         setlocal modifiable | silent put! f | setlocal nomodifiable
789         let @f=save_f
790 endfunction " >>>
792 let &cpo = s:cpo_save
794 " vim: set ts=2 sw=2 foldmethod=marker foldmarker=<<<,>>> foldlevel=2 :