diff --git a/vimfiles/GetLatest/GetLatestVimScripts.dat b/vimfiles/GetLatest/GetLatestVimScripts.dat index 2378752..dd8b41e 100644 --- a/vimfiles/GetLatest/GetLatestVimScripts.dat +++ b/vimfiles/GetLatest/GetLatestVimScripts.dat @@ -26,11 +26,11 @@ ScriptID SourceID Filename 294 19633 Align.vim 479 9276 MultipleSearch.vba 1066 7618 cecutil.vim -1173 19247 tComment.vim +1173 21766 tComment.vim 2701 18988 editsrec 3280 14334 Tabbi 642 15781 :AutoInstall: getscript.vim -1075 19823 :AutoInstall: netrw.vim +1075 21427 :AutoInstall: netrw.vim 1502 15362 :AutoInstall: vimball.vim 3304 20505 Gundo 90 19809 vcscommand diff --git a/vimfiles/autoload/netrw.vim b/vimfiles/autoload/netrw.vim index 8849238..4634a34 100644 --- a/vimfiles/autoload/netrw.vim +++ b/vimfiles/autoload/netrw.vim @@ -1,10 +1,10 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION -" Date: Apr 15, 2013 -" Version: 147 +" Date: Jan 21, 2014 +" Version: 150 " Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim -" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 +" Copyright: Copyright (C) 1999-2013 Charles E. Campbell {{{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, @@ -22,13 +22,7 @@ if &cp || exists("g:loaded_netrw") finish endif -let g:loaded_netrw = "v147" -if v:version < 703 || (v:version == 703 && !has("patch465")) - echohl WarningMsg - echo "***warning*** this version of netrw needs vim 7.3.465 or later" - echohl Normal - finish -endif +let g:loaded_netrw = "v150" if !exists("s:NOTE") let s:NOTE = 0 let s:WARNING = 1 @@ -37,7 +31,7 @@ endif let s:keepcpo= &cpo set cpo&vim -"DechoTabOn +"DechoRemOn "call Decho("doing autoload/netrw.vim version ".g:loaded_netrw) " ====================== @@ -49,12 +43,12 @@ set cpo&vim " 0=note = s:NOTE " 1=warning = s:WARNING " 2=error = s:ERROR -" Apr 02, 2013 : max errnum currently is 92 +" Jan 03, 2014 : max errnum currently is 95 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) if a:level < g:netrw_errorlvl -" call Dret("netrw#ErrorMsg : suppressing level=".a:level." since g;netrw_errorlvl=".g:netrw_errorlvl) +" call Dret("netrw#ErrorMsg : suppressing level=".a:level." since g:netrw_errorlvl=".g:netrw_errorlvl) return endif @@ -128,7 +122,7 @@ endfun " NetrwInit: initializes variables if they haven't been defined {{{2 " Loosely, varname = value. fun s:NetrwInit(varname,value) -" call Decho("varname<".a:varname."> value=".a:value) +" call Decho("varname<".a:varname."> value=".a:value) if !exists(a:varname) if type(a:value) == 0 exe "let ".a:varname."=".a:value @@ -200,9 +194,23 @@ if !exists("g:netrw_http_cmd") let g:netrw_http_cmd = "" endif endif +call s:NetrwInit("g:netrw_http_put_cmd","curl -T") call s:NetrwInit("g:netrw_rcp_cmd" , "rcp") call s:NetrwInit("g:netrw_rsync_cmd", "rsync") -call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") +if !exists("g:netrw_scp_cmd") + if executable("scp") + call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") + elseif executable("pscp") + if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable('c:\private.ppk') + call s:NetrwInit("g:netrw_scp_cmd", 'pscp -i c:\private.ppk') + else + call s:NetrwInit("g:netrw_scp_cmd", 'pscp -q') + endif + else + call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") + endif +endif + call s:NetrwInit("g:netrw_sftp_cmd" , "sftp") call s:NetrwInit("g:netrw_ssh_cmd" , "ssh") @@ -247,6 +255,7 @@ endif call s:NetrwInit("g:netrw_cursor" , 2) let s:netrw_usercul = &cursorline let s:netrw_usercuc = &cursorcolumn +call s:NetrwInit("g:netrw_cygdrive","/cygdrive") " Default values - d-g ---------- {{{3 call s:NetrwInit("s:didstarstar",0) call s:NetrwInit("g:netrw_dirhist_cnt" , 0) @@ -279,13 +288,13 @@ endif call s:NetrwInit("g:netrw_keepdir",1) if !exists("g:netrw_list_cmd") if g:netrw_scp_cmd =~ '^pscp' && executable("pscp") - " provide a 'pscp' listing command if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk") + " provide a pscp-based listing command let g:netrw_scp_cmd ="pscp -i C:\\private.ppk" endif let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:" elseif executable(g:netrw_ssh_cmd) - " provide a default listing command + " provide a scp-based default listing command let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa" else " call Decho(g:netrw_ssh_cmd." is not executable") @@ -417,6 +426,11 @@ endif call s:NetrwInit("g:netrw_menu_escape",'.&? \') call s:NetrwInit("g:netrw_tmpfile_escape",' &;') call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\\"") +if &enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4' + let s:treedepthstring= "│ " +else + let s:treedepthstring= "| " +endif " BufEnter event ignored by decho when following variable is true " Has a side effect that doau BufReadPost doesn't work, so @@ -427,11 +441,18 @@ call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\\"") " Netrw Initialization: {{{1 " ====================== if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") - let s:initbeval = &beval -" let s:initbexpr = &l:bexpr - let &l:bexpr = "netrw#NetrwBalloonHelp()" - set beval - au BufWinEnter,WinEnter * if &ft == "netrw"|set beval|else|let &beval= s:initbeval|endif +" call Decho("installed beval events") + let &l:bexpr = "netrw#NetrwBalloonHelp()" + au FileType netrw set beval + au WinLeave * if &ft == "netrw" && exists("s:initbeval")|let &beval= s:initbeval|endif + au VimEnter * let s:initbeval= &beval +"else " Decho +" if v:version < 700 | call Decho("did not install beval events: v:version=".v:version." < 700") | endif +" if !has("balloon_eval") | call Decho("did not install beval events: does not have balloon_eval") | endif +" if exists("s:initbeval") | call Decho("did not install beval events: s:initbeval exists") | endif +" if exists("g:netrw_nobeval") | call Decho("did not install beval events: g:netrw_nobeval exists") | endif +" if !has("syntax") | call Decho("did not install beval events: does not have syntax highlighting") | endif +" if exists("g:syntax_on") | call Decho("did not install beval events: g:syntax_on exists") | endif endif au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif @@ -441,41 +462,53 @@ au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif " --------------------------------------------------------------------- " netrw#NetrwBalloonHelp: {{{2 -if v:version >= 700 && has("balloon_eval") && &beval == 1 && has("syntax") && exists("g:syntax_on") - fun! netrw#NetrwBalloonHelp() - if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval) - let mesg= "" - elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing" - let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file" - elseif getline(v:beval_lnum) =~ '^"\s*/' - let mesg = ": edit/enter o: edit/enter in horiz window t: edit/enter in new tab v:edit/enter in vert window" - elseif v:beval_text == "Sorted" || v:beval_text == "by" - let mesg = 's: sort by name, time, or file size r: reverse sorting order mt: mark target' - elseif v:beval_text == "Sort" || v:beval_text == "sequence" - let mesg = "S: edit sorting sequence" - elseif v:beval_text == "Hiding" || v:beval_text == "Showing" - let mesg = "a: hiding-showing-all ctrl-h: editing hiding list mh: hide/show by suffix" - elseif v:beval_text == "Quick" || v:beval_text == "Help" - let mesg = "Help: press " - elseif v:beval_text == "Copy/Move" || v:beval_text == "Tgt" - let mesg = "mt: mark target mc: copy marked file to target mm: move marked file to target" - else - let mesg= "" - endif - return mesg - endfun +if v:version >= 700 && has("balloon_eval") && has("syntax") && exists("g:syntax_on") && !exists("g:netrw_nobeval") +" call Decho("loading netrw#BalloonHelp()") + fun! netrw#NetrwBalloonHelp() + if &ft != "netrw" + return "" + endif + if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval) + let mesg= "" + elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing" + let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file" + elseif getline(v:beval_lnum) =~ '^"\s*/' + let mesg = ": edit/enter o: edit/enter in horiz window t: edit/enter in new tab v:edit/enter in vert window" + elseif v:beval_text == "Sorted" || v:beval_text == "by" + let mesg = 's: sort by name, time, or file size r: reverse sorting order mt: mark target' + elseif v:beval_text == "Sort" || v:beval_text == "sequence" + let mesg = "S: edit sorting sequence" + elseif v:beval_text == "Hiding" || v:beval_text == "Showing" + let mesg = "a: hiding-showing-all ctrl-h: editing hiding list mh: hide/show by suffix" + elseif v:beval_text == "Quick" || v:beval_text == "Help" + let mesg = "Help: press " + elseif v:beval_text == "Copy/Move" || v:beval_text == "Tgt" + let mesg = "mt: mark target mc: copy marked file to target mm: move marked file to target" + else + let mesg= "" + endif + return mesg + endfun +"else " Decho +" if v:version < 700 |call Decho("did not load netrw#BalloonHelp(): vim version ".v:version." < 700 -")|endif +" if !has("balloon_eval") |call Decho("did not load netrw#BalloonHelp(): does not have balloon eval") |endif +" if !has("syntax") |call Decho("did not load netrw#BalloonHelp(): syntax disabled") |endif +" if !exists("g:syntax_on") |call Decho("did not load netrw#BalloonHelp(): g:syntax_on=".g:syntax_on) |endif +" if exists("g:netrw_nobeval") |call Decho("did not load netrw#BalloonHelp(): g:netrw_nobeval exists") |endif endif " ------------------------------------------------------------------------ " s:NetrwOptionSave: save options prior to setting to "netrw-buffer-standard" form {{{2 +" Options get restored by s:NetrwOptionRestore() " 06/08/07 : removed call to NetrwSafeOptions(), either placed " immediately after NetrwOptionSave() calls in NetRead " and NetWrite, or after the s:NetrwEnew() call in " NetrwBrowse. " vt: normally its "w:" or "s:" (a variable type) fun! s:NetrwOptionSave(vt) -" call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")) +" call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma) " call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist")) +" call Decho("(s:NetrwOptionSave) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) if !exists("{a:vt}netrw_optionsave") let {a:vt}netrw_optionsave= 1 @@ -483,7 +516,7 @@ fun! s:NetrwOptionSave(vt) " call Dret("s:NetrwOptionSave : options already saved") return endif -" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) +" call Decho("(s:NetrwOptionSave) prior to save: fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) " Save current settings and current directory " call Decho("saving current settings and current directory") @@ -518,6 +551,7 @@ fun! s:NetrwOptionSave(vt) let {a:vt}netrw_rokeep = &l:ro let {a:vt}netrw_selkeep = &l:sel let {a:vt}netrw_spellkeep = &l:spell + let {a:vt}netrw_starkeep = @* let {a:vt}netrw_tskeep = &l:ts let {a:vt}netrw_twkeep = &l:tw " textwidth let {a:vt}netrw_wigkeep = &l:wig " wildignore @@ -538,13 +572,15 @@ fun! s:NetrwOptionSave(vt) if &go =~# 'a' | sil! let {a:vt}netrw_regstar = @* | endif sil! let {a:vt}netrw_regslash= @/ -" call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) +" call Decho("(s:NetrwOptionSave) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) +" call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr()) endfun " ------------------------------------------------------------------------ -" s:NetrwOptionRestore: restore options {{{2 +" s:NetrwOptionRestore: restore options (based on prior s:NetrwOptionSave) {{{2 fun! s:NetrwOptionRestore(vt) " call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$")) +" call Decho("(NetrwOptionRestore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) if !exists("{a:vt}netrw_optionsave") if exists("s:nbcd_curpos_{bufnr('%')}") " call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)") @@ -555,6 +591,7 @@ fun! s:NetrwOptionRestore(vt) else " call Decho("(NetrwOptionRestore) no previous position") endif +" call Decho("(NetrwOptionRestore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) " call Decho("(NetrwOptionRestore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") " call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist") return @@ -610,6 +647,7 @@ fun! s:NetrwOptionRestore(vt) if exists("{a:vt}netrw_rokeep") |let &l:ro = {a:vt}netrw_rokeep |unlet {a:vt}netrw_rokeep |endif if exists("{a:vt}netrw_selkeep") |let &l:sel = {a:vt}netrw_selkeep |unlet {a:vt}netrw_selkeep |endif if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif + if exists("{a:vt}netrw_starkeep") |let @* = {a:vt}netrw_starkeep |unlet {a:vt}netrw_starkeep |endif " Problem: start with liststyle=0; press : result, following line resets l:ts. " if exists("{a:vt}netrw_tskeep") |let &l:ts = {a:vt}netrw_tskeep |unlet {a:vt}netrw_tskeep |endif if exists("{a:vt}netrw_twkeep") |let &l:tw = {a:vt}netrw_twkeep |unlet {a:vt}netrw_twkeep |endif @@ -622,7 +660,7 @@ fun! s:NetrwOptionRestore(vt) " user hasn't specified a swapfile directory; " netrw will temporarily set the swapfile directory " to the current directory as returned by getcwd(). - let &l:directory = getcwd() + let &l:directory= getcwd() sil! let &l:swf = {a:vt}netrw_swfkeep setl directory= unlet {a:vt}netrw_swfkeep @@ -642,7 +680,9 @@ fun! s:NetrwOptionRestore(vt) " call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)") keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')}) " call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%')) - unlet s:nbcd_curpos_{bufnr('%')} + if exists("s:nbcd_curpos_".bufnr('%')) + unlet s:nbcd_curpos_{bufnr('%')} + endif else " call Decho("no previous position") endif @@ -659,6 +699,7 @@ fun! s:NetrwOptionRestore(vt) " call Decho("(NetrwOptionRestore) filetype detect (ft=".&ft.")") filetype detect endif +" call Decho("(s:NetrwOptionRestore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) " call Dret("s:NetrwOptionRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) endfun @@ -668,10 +709,12 @@ endfun " Use s:NetrwOptionRestore() to restore user settings fun! s:NetrwSafeOptions() " call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$")) -" call Decho("win#".winnr()."'s ft=".&ft) +" call Decho("(s:NetrwSafeOptions) win#".winnr()."'s ft=".&ft) +" call Decho("(s:NetrwSafeOptions) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) if exists("+acd") | setl noacd | endif setl noai setl noaw + setl nobl setl nobomb setl noci setl nocin @@ -683,7 +726,7 @@ fun! s:NetrwSafeOptions() setl cpo-=a setl cpo-=A setl fo=nroql2 - setl nohid + setl nohid setl noim setl isk+=@ isk+=* isk+=/ setl magic @@ -699,13 +742,14 @@ fun! s:NetrwSafeOptions() call s:NetrwCursor() " allow the user to override safe options -" call Decho("ft<".&ft."> ei=".&ei) +" call Decho("(s:NetrwSafeOptions) ft<".&ft."> ei=".&ei) if &ft == "netrw" -" call Decho("do any netrw FileType autocmds (doau FileType netrw)") +" call Decho("(s:NetrwSafeOptions) do any netrw FileType autocmds (doau FileType netrw)") sil! keepalt keepj doau FileType netrw endif -" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh) +" call Decho("(s:NetrwSafeOptions) fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh) +" call Decho("(s:NetrwSafeOptions) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwSafeOptions") endfun @@ -720,7 +764,7 @@ endfun " * 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==0: the window will be split iff the current file has been modified and hidden not set " dosplit==1: the window will be split before running the local browser " style == 0: Explore style == 1: Explore! " == 2: Hexplore style == 3: Hexplore! @@ -734,6 +778,9 @@ fun! netrw#Explore(indx,dosplit,style,...) endif let curdir = simplify(b:netrw_curdir) let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') + if !exists("g:netrw_cygwin") && (has("win32") || has("win95") || has("win64") || has("win16")) + let curdir= substitute(curdir,'\','/','g') + endif " call Decho("(Explore) curdir<".curdir."> curfiledir<".curfiledir.">") " save registers @@ -741,8 +788,10 @@ fun! netrw#Explore(indx,dosplit,style,...) sil! let keepregplus = @+ sil! let keepregslash= @/ - " if dosplit or file has been modified - if a:dosplit || &modified || a:style == 6 + " if dosplit + " -or- file has been modified AND file not hidden when abandoned + " -or- Texplore used + if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") || a:style == 6 " call Decho("(Explore) case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified") call s:SaveWinVars() let winsz= g:netrw_winsize @@ -793,7 +842,7 @@ fun! netrw#Explore(indx,dosplit,style,...) keepj norm! 0 if a:0 > 0 -" call Decho("(Explore) case [a:0=".a:0."] > 0") +" call Decho("(Explore) case [a:0=".a:0."] > 0: a:1<".a:1.">") if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)) " call Decho("(Explore) ..case a:1<".a:1.">: starts with ~ and unix or cygwin") let dirname= simplify(substitute(a:1,'\~',expand("$HOME"),'')) @@ -809,7 +858,7 @@ fun! netrw#Explore(indx,dosplit,style,...) " call Decho("(Explore) ..case a:1<".a:1.">: matches ending $") let dirname= simplify(expand(a:1)) " call Decho("(Explore) ..using user-specified dirname<".dirname."> with $env-var") - elseif a:1 !~ '^\*\{1,2}/' + elseif a:1 !~ '^\*\{1,2}/' && a:1 !~ '^\a\{3,}://' " call Decho("(Explore) ..case a:1<".a:1.">: other, not pattern or filepattern") let dirname= simplify(a:1) " call Decho("(Explore) ..using user-specified dirname<".dirname.">") @@ -835,7 +884,7 @@ fun! netrw#Explore(indx,dosplit,style,...) if dirname =~ '^\*//' " starpat=1: Explore *//pattern (current directory only search for files containing pattern) -" call Decho("(Explore) case Explore *//pattern") +" call Decho("(Explore) case starpat=1: Explore *//pattern") let pattern= substitute(dirname,'^\*//\(.*\)$','\1','') let starpat= 1 " call Decho("(Explore) ..Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") @@ -843,14 +892,14 @@ fun! netrw#Explore(indx,dosplit,style,...) elseif dirname =~ '^\*\*//' " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) -" call Decho("(Explore) case Explore **//pattern") +" call Decho("(Explore) case starpat=2: Explore **//pattern") let pattern= substitute(dirname,'^\*\*//','','') let starpat= 2 " call Decho("(Explore) ..Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") elseif dirname =~ '/\*\*/' " handle .../**/.../filepat -" call Decho("(Explore) case Explore .../**/.../filepat") +" call Decho("(Explore) case starpat=4: Explore .../**/.../filepat") let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','') if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) let b:netrw_curdir = prefixdir @@ -863,32 +912,40 @@ fun! netrw#Explore(indx,dosplit,style,...) " call Decho("(Explore) ..case Explore ../**/../filepat (starpat=".starpat.")") elseif dirname =~ '^\*/' - " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) + " case starpat=3: Explore */filepat (search in current directory for filenames matching filepat) let starpat= 3 -" call Decho("(Explore) case Explore */filepat (starpat=".starpat.")") +" call Decho("(Explore) case starpat=3: Explore */filepat (starpat=".starpat.")") elseif dirname=~ '^\*\*/' " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) let starpat= 4 -" call Decho("(Explore) case Explore **/filepat (starpat=".starpat.")") +" call Decho("(Explore) case starpat=4: Explore **/filepat (starpat=".starpat.")") else let starpat= 0 -" call Decho("(Explore) default case: starpat=".starpat) +" call Decho("(Explore) case starpat=0: default") endif if starpat == 0 && a:indx >= 0 " [Explore Hexplore Vexplore Sexplore] [dirname] -" call Decho("(Explore) case starpat==0 && a:indx=".a:indx.": dirname<".dirname."> Explore Hexplore Vexplore Sexplore") +" call Decho("(Explore) case starpat==0 && a:indx=".a:indx.": dirname<".dirname.">, handles Explore Hexplore Vexplore Sexplore") if dirname == "" let dirname= curfiledir " call Decho("(Explore) ..empty dirname, using current file's directory<".dirname.">") endif - if dirname =~ '^scp:' || dirname =~ '^ftp:' -" call Decho("(Explore) ..calling NetrwBrowse(0,dirname<".dirname.">)") - call s:NetrwBrowse(0,dirname) + if dirname =~ '^scp://' || dirname =~ '^ftp://' + call netrw#Nread(2,dirname) + "call s:NetrwBrowse(0,dirname) else - if dirname == ""|let dirname= getcwd()|endif + if dirname == "" + let dirname= getcwd() + elseif (has("win32") || has("win95") || has("win64") || has("win16")) && !g:netrw_cygwin + if dirname !~ '^[a-zA-Z]:' + let dirname= b:netrw_curdir."/".dirname + endif + elseif dirname !~ '^/' + let dirname= b:netrw_curdir."/".dirname + endif " call Decho("(Explore) ..calling LocalBrowseCheck(dirname<".dirname.">)") call netrw#LocalBrowseCheck(dirname) " call Decho("(Explore) win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) @@ -1120,11 +1177,11 @@ fun! netrw#Explore(indx,dosplit,style,...) if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") " call Decho("(Explore) s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-")) if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir - " only update match list if current directory isn't the same as before -" call Decho("(Explore) only update match list if current directory not the same as before") + " only update match list when current directory isn't the same as before +" call Decho("(Explore) only update match list when current directory not the same as before") let s:explore_prvdir = b:netrw_curdir let s:explore_match = "" - let dirlen = s:Strlen(b:netrw_curdir) + let dirlen = strlen(b:netrw_curdir) if b:netrw_curdir !~ '/$' let dirlen= dirlen + 1 endif @@ -1164,6 +1221,37 @@ fun! netrw#Explore(indx,dosplit,style,...) " call Dret("netrw#Explore : @/<".@/.">") endfun +" --------------------------------------------------------------------- +" netrw#Lexplore: toggle Explorer window, keeping it on the left of the current tab {{{2 +fun! netrw#Lexplore(...) +" call Dfunc("netrw#Lexplore() a:0=".a:0) + if exists("t:netrw_lexbufnr") + " close down netrw explorer window + let lexwinnr = bufwinnr(t:netrw_lexbufnr) + if lexwinnr != -1 + let curwin = winnr() + exe lexwinnr."wincmd w" + close + exe curwin."wincmd w" + endif + unlet t:netrw_lexbufnr + + else + " open netrw explorer window + exe "1wincmd w" + let keep_altv = g:netrw_altv + let g:netrw_altv = 0 + if a:0 > 0 && a:1 != "" + Vexplore a:1 + else + Vexplore . + endif + let g:netrw_altv = keep_altv + let t:netrw_lexbufnr = bufnr("%") + endif +" call Dret("netrw#Lexplore") +endfun + " --------------------------------------------------------------------- " netrw#NetrwMakeTgt: make a target out of the directory name provided {{{2 fun! netrw#NetrwMakeTgt(dname) @@ -1508,7 +1596,7 @@ endfun " =2 replace with remote file " =3 obtain file, but leave in temporary format fun! netrw#NetRead(mode,...) -" call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw) +" call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw.((a:0 > 0)? " a:1<".a:1.">" : "")) " NetRead: save options {{{3 call s:NetrwOptionSave("w:") @@ -1606,7 +1694,7 @@ fun! netrw#NetRead(mode,...) endif let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix - " Check if NetrwBrowse() should be handling this request + " Check whether or not NetrwBrowse() should be handling this request " call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' " call Decho("yes, choice matches '^.*[\/]$'") @@ -1628,7 +1716,7 @@ fun! netrw#NetRead(mode,...) " call Decho("read via rcp (method #1)") " ER: nothing done with g:netrw_uid yet? " ER: on Win2K" rcp machine[.user]:file tmpfile - " ER: if machine contains '.' adding .user is required (use $USERNAME) + " ER: when machine contains '.' adding .user is required (use $USERNAME) " ER: the tmpfile is full path: rcp sees C:\... as host C if s:netrw_has_nt_rcp == 1 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) @@ -1947,7 +2035,7 @@ fun! netrw#NetWrite(...) range exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) elseif g:netrw_cygwin " write (selected portion of) file to temporary - let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','') + let cygtmpfile= substitute(tmpfile,g:netrw_cygdrive.'/\(.\)','\1:','') " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)) exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile) else @@ -1957,7 +2045,7 @@ fun! netrw#NetWrite(...) range endif if curbufname == "" - " if the file is [No Name], and one attempts to Nwrite it, the buffer takes + " when the file is [No Name], and one attempts to Nwrite it, the buffer takes " on the temporary file's name. Deletion of the temporary file during " cleanup then causes an error message. 0file! @@ -1975,7 +2063,7 @@ fun! netrw#NetWrite(...) range else exe "let choice= a:" . ichoice - " Reconstruct Choice if choice starts with '"' + " Reconstruct Choice when choice starts with '"' if match(choice,"?") == 0 echomsg 'NetWrite Usage:"' echomsg ':Nwrite machine:path uses rcp' @@ -2184,8 +2272,13 @@ fun! netrw#NetWrite(...) range " NetWrite: (http) NetWrite Method #5 {{{3 elseif b:netrw_method == 5 " call Decho("write via http (method #5)") - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"currently does not support writing using http:",16) + let curl= substitute(g:netrw_http_put_cmd,'\s\+.*$',"","") + if executable(curl) + let url= g:netrw_choice +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".shellescape(tmpfile,1)." ".shellescape(url,1) ) + exe s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".shellescape(tmpfile,1)." ".shellescape(url,1) + elseif !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd".">".",16) endif "......................................... @@ -2332,6 +2425,36 @@ fun! netrw#NetSource(...) " call Dret("netrw#NetSource") endfun +" --------------------------------------------------------------------- +" netrw#NetrwSetTreetop: resets the tree top to the current directory/specified directory {{{2 +fun! netrw#NetrwSetTreetop(...) +" call Dfunc("netrw#NetrwSetTreetop(".((a:0 > 0)? a:1 : "").") a:0=".a:0) + " clear out the current tree + if exists("w:netrw_treetop") + let inittreetop= w:netrw_treetop + unlet w:netrw_treetop + endif + if exists("w:netrw_treedict") + unlet w:netrw_treedict + endif + if a:1 == "" + let treedir= s:NetrwTreePath(inittreetop) + else + if isdirectory(a:1) + let treedir= a:1 + elseif exists("b:netrw_curdir") && isdirectory(b:netrw_curdir."/".a:1) + let treedir= b:netrw_curdir."/".a:1 + else + call netrw#ErrorMsg(s:ERROR,"sorry, ".a:1." doesn't seem to be a directory!",95) +" call Dret("netrw#NetrwSetTreetop") + return + endif + endif +" call Decho("treedir<".treedir.">") + sil! call netrw#LocalBrowseCheck(treedir) +" call Dret("netrw#NetrwSetTreetop") +endfun + " =========================================== " s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 " readcmd == %r : replace buffer with newly read file @@ -2363,7 +2486,7 @@ fun! s:NetrwGetFile(readcmd, tfile, method) " rename the current buffer to the temp file (ie. tfile) if g:netrw_cygwin - let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','') + let tfile= substitute(a:tfile,g:netrw_cygdrive.'/\(.\)','\1:','') else let tfile= a:tfile endif @@ -2410,6 +2533,12 @@ fun! s:NetrwGetFile(readcmd, tfile, method) let line1 = 1 let line2 = line("$") + elseif !&ma + " attempting to read a file after the current line in the file, but the buffer is not modifiable + keepj call netrw#ErrorMsg(s:WARNING,"attempt to read<".a:tfile."> into a non-modifiable buffer!",94) +" call Dret("NetrwGetFile : attempt to read<".a:tfile."> into a non-modifiable buffer!") + return + elseif s:FileReadable(a:tfile) " read file after current line " call Decho("read file<".a:tfile."> after current line") @@ -2611,8 +2740,7 @@ fun! s:NetrwMethod(choice) " call Decho("has -s: : s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">") " call Decho(" g:netrw_ftp_cmd<".g:netrw_ftp_cmd.">") if g:netrw_ftp_cmd =~ '-[sS]:\S*MACHINE\>' - let machine = substitute(g:netrw_machine,'\([^.]\+\)\.\S*','\1','') - let s:netrw_ftp_cmd= substitute(g:netrw_ftp_cmd,'\',machine.".ftp",'') + let s:netrw_ftp_cmd= substitute(g:netrw_ftp_cmd,'\',g:netrw_machine,'') " call Decho("s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">") endif let b:netrw_method= 2 @@ -2883,7 +3011,7 @@ fun! s:NetrwMaps(islocal) " local normal-mode maps nnoremap a :call NetrwHide(1) nnoremap % :call NetrwOpenFile(1) - nnoremap c :exe "keepjumps lcd ".fnameescape(b:netrw_curdir) + nnoremap c :exe "keepj lcd ".fnameescape(b:netrw_curdir) nnoremap C :let g:netrw_chgwin= winnr() nnoremap :call netrw#LocalBrowseCheck(NetrwBrowseChgDir(1,NetrwGetWord())) nnoremap d :call NetrwMakeDir("") @@ -3000,22 +3128,22 @@ fun! s:NetrwMaps(islocal) endif let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape) if g:netrw_mousemaps == 1 - nmap NetrwLeftmouse - nno NetrwLeftmouse :call NetrwLeftmouse(1) - nmap NetrwRightdrag - nno NetrwRightdrag :call NetrwRightdrag(1) - nmap NetrwMiddlemouse - nno NetrwMiddlemouse :call NetrwPrevWinOpen(1) - nmap NetrwSLeftmouse - nno NetrwSLeftmouse :call NetrwMarkFile(1,NetrwGetWord()) - nmap <2-leftmouse> Netrw2Leftmouse - nmap Netrw2Leftmouse - - imap ILeftmouse - ino ILeftmouse :call NetrwLeftmouse(1) - imap IMiddlemouse - ino IMiddlemouse :call NetrwPrevWinOpen(1) - imap ISLeftmouse - ino ISLeftmouse :call NetrwMarkFile(1,NetrwGetWord()) + nmap NetrwLeftmouse + nno NetrwLeftmouse :call NetrwLeftmouse(1) + nmap NetrwMiddlemouse + nno NetrwMiddlemouse :call NetrwPrevWinOpen(1) + nmap NetrwSLeftmouse + nno NetrwSLeftmouse :call NetrwSLeftmouse(1) + nmap NetrwSLeftdrag + nno NetrwSLeftdrag :call NetrwSLeftdrag(1) + nmap <2-leftmouse> Netrw2Leftmouse + nmap Netrw2Leftmouse - + imap ILeftmouse + ino ILeftmouse :call NetrwLeftmouse(1) + imap IMiddlemouse + ino IMiddlemouse :call NetrwPrevWinOpen(1) + imap ISLeftmouse + ino ISLeftmouse :call NetrwMarkFile(1,NetrwGetWord()) exe 'nnoremap :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'vnoremap :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'inoremap :call NetrwLocalRm("'.mapsafecurdir.'")' @@ -3023,15 +3151,15 @@ fun! s:NetrwMaps(islocal) exe 'nnoremap :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'nnoremap D :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'nnoremap R :call NetrwLocalRename("'.mapsafecurdir.'")' - exe 'nnoremap m :call NetrwMakeDir("")' + exe 'nnoremap d :call NetrwMakeDir("")' exe 'vnoremap :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'vnoremap D :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'vnoremap R :call NetrwLocalRename("'.mapsafecurdir.'")' exe 'inoremap :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'inoremap D :call NetrwLocalRm("'.mapsafecurdir.'")' exe 'inoremap R :call NetrwLocalRename("'.mapsafecurdir.'")' - exe 'inoremap m :call NetrwMakeDir("")' - nnoremap :he netrw-quickhelp + exe 'inoremap d :call NetrwMakeDir("")' + nnoremap :he netrw-quickhelp else " remote " call Decho("(NetrwMaps) make remote maps") @@ -3152,10 +3280,12 @@ fun! s:NetrwMaps(islocal) nno NetrwLeftmouse :call NetrwLeftmouse(0) nmap NetrwLeftdrag nno NetrwLeftdrag :call NetrwLeftdrag(0) + nmap NetrwSLeftmouse + nno NetrwSLeftmouse :call NetrwSLeftmouse(0) + nmap NetrwSLeftdrag + nno NetrwSLeftdrag :call NetrwSLeftdrag(0) nmap NetrwMiddlemouse nno NetrwMiddlemouse :call NetrwPrevWinOpen(0) - nmap NetrwSLeftmouse - nno NetrwSLeftmouse :call NetrwMarkFile(0,NetrwGetWord()) nmap <2-leftmouse> Netrw2Leftmouse nmap Netrw2Leftmouse - imap ILeftmouse @@ -3315,7 +3445,7 @@ fun! s:NetrwBookHistHandler(chg,curdir) " call Decho("(NetrwBookHistHandler) setl nomod") " call Decho("(NetrwBookHistHandler) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") endif -" " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) +" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) else if g:netrw_dirhistmax > 0 @@ -3597,11 +3727,14 @@ fun! s:NetrwBrowse(islocal,dirname) endif " set b:netrw_curdir to the new directory name {{{3 -" call Decho("(NetrwBrowse) set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")") +" call Decho("(NetrwBrowse) set b:netrw_curdir to the new directory name<".dirname."> (buf#".bufnr("%").")") let b:netrw_curdir= dirname if b:netrw_curdir =~ '[/\\]$' let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') endif + if b:netrw_curdir =~ '\a:$' && (has("win32") || has("win95") || has("win64") || has("win16")) + let b:netrw_curdir= b:netrw_curdir."/" + endif if b:netrw_curdir == '' if has("amiga") " On the Amiga, the empty string connotes the current directory @@ -3631,7 +3764,7 @@ fun! s:NetrwBrowse(islocal,dirname) " call Decho("(NetrwBrowse) handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) " call Decho("(NetrwBrowse) l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) if !exists("&l:acd") || !&l:acd -" call Decho('exe keepjumps lcd '.fnameescape(b:netrw_curdir)) +" call Decho('(NetrwBrowse) exe keepj lcd '.fnameescape(b:netrw_curdir)) try exe 'keepj lcd '.fnameescape(b:netrw_curdir) catch /^Vim\%((\a\+)\)\=:E472/ @@ -3718,20 +3851,33 @@ endfun " --------------------------------------------------------------------- " s:NetrwFileInfo: supports qf (query for file information) {{{2 fun! s:NetrwFileInfo(islocal,fname) -" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">)") +" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">) b:netrw_curdir<".b:netrw_curdir.">") let ykeep= @@ if a:islocal if (has("unix") || has("macunix")) && executable("/bin/ls") - if exists("b:netrw_curdir") -" call Decho('using ls with b:netrw_curdir<'.b:netrw_curdir.'>') + + if getline(".") == "../" + echo system("/bin/ls -lsad ".shellescape("..")) +" call Decho("#1: echo system(/bin/ls -lsad ".shellescape(..).")") + + elseif getline(".") !~ '^'.s:treedepthstring + echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir)) +" call Decho("#2: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir).")") + + elseif exists("b:netrw_curdir") if b:netrw_curdir =~ '/$' echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname)) +" call Decho("#3: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname).")") + else echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname)) +" call Decho("#4: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname).")") endif + else " call Decho('using ls '.a:fname." using cwd<".getcwd().">") echo system("/bin/ls -lsad ".shellescape(a:fname)) +" call Decho("#5: echo system(/bin/ls -lsad ".shellescape(a:fname).")") endif else " use vim functions to return information about file below cursor @@ -3759,6 +3905,7 @@ endfun " 1=re-used buffer fun! s:NetrwGetBuffer(islocal,dirname) " call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) let dirname= a:dirname " re-use buffer if possible {{{3 @@ -3767,12 +3914,14 @@ fun! s:NetrwGetBuffer(islocal,dirname) " find NetrwTreeList buffer if there is one " call Decho("(NetrwGetBuffer) case liststyle=treelist: find NetrwTreeList buffer if there is one") if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 -" call Decho("(NetrwGetBuffer) re-use w:netrw_treebufnr=".w:netrw_treebufnr) - sil keepj %d +" call Decho("(NetrwGetBuffer) re-using w:netrw_treebufnr=".w:netrw_treebufnr) let eikeep= &ei set ei=all exe "sil! keepalt b ".w:netrw_treebufnr let &ei= eikeep + setl ma + sil! keepj %d +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwGetBuffer 0 : bufnum#".w:netrw_treebufnr."") return 0 endif @@ -3782,7 +3931,7 @@ fun! s:NetrwGetBuffer(islocal,dirname) else " find buffer number of buffer named precisely the same as dirname {{{3 " call Decho("(NetrwGetBuffer) case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") -" call Dredir("ls!") +" call Dredir("(NetrwGetBuffer) ls!","ls!") " get dirname and associated buffer number let bufnum = bufnr(escape(dirname,'\')) @@ -3904,11 +4053,13 @@ fun! s:NetrwGetBuffer(islocal,dirname) let &ei= eikeep if line("$") <= 1 keepj call s:NetrwListSettings(a:islocal) +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but its empty, so refresh it") return 0 elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1) keepj call s:NetrwListSettings(a:islocal) sil keepj %d +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) return 0 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST @@ -3916,9 +4067,11 @@ fun! s:NetrwGetBuffer(islocal,dirname) " call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") sil keepj %d keepj call s:NetrwListSettings(a:islocal) +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") return 0 else +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwGetBuffer 1 : buf#".bufnr("%")) return 1 endif @@ -3940,7 +4093,8 @@ fun! s:NetrwGetBuffer(islocal,dirname) " call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") sil! keepalt keepj %d -" call Dret("s:NetrwGetBuffer 0 : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) +" call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) +" call Dret("s:NetrwGetBuffer 0 : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")) return 0 endfun @@ -4019,7 +4173,7 @@ fun! s:NetrwGetWord() elseif w:netrw_liststyle == s:TREELIST " call Decho("treelist handling") - let dirname= substitute(getline('.'),'^\(| \)*','','e') + let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') else " call Decho("obtain word from wide listing") @@ -4071,6 +4225,7 @@ endfun " s:NetrwListSettings: make standard settings for a netrw listing {{{2 fun! s:NetrwListSettings(islocal) " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") +" call Decho("(s:NetrwListSettings) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) let fname= bufname("%") " call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro") setl bt=nofile nobl ma nonu nowrap noro @@ -4088,6 +4243,7 @@ fun! s:NetrwListSettings(islocal) else setl bh=delete endif +" call Decho("(s:NetrwListSettings) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwListSettings") endfun @@ -4270,6 +4426,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) endif " NetrwBrowseChgDir: save options and initialize {{{3 +" call Decho("(NetrwBrowseChgDir) saving options") keepj call s:NetrwOptionSave("s:") keepj call s:NetrwSafeOptions() let nbcd_curpos = netrw#NetrwSavePosn() @@ -4284,6 +4441,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) let dolockout = 0 " set up o/s-dependent directory recognition pattern +" call Decho("(NetrwBrowseChgDir) set up o/s-dependent directory recognition pattern") if has("amiga") let dirpat= '[\/:]$' else @@ -4308,12 +4466,14 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) let s:rexposn_{bufnr("%")}= netrw#NetrwSavePosn() " call Decho("(NetrwBrowseChgDir:edit-a-file) setting s:rexposn_".bufnr("%")." to SavePosn") +" call Decho("(NetrwBrowseChgDir:edit-a-file) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft) if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)' +" call Decho("(NetrwBrowseChgDir:edit-a-file) handle tree listing: w:netrw_treedict<".(exists("w:netrw_treedict")? string(w:netrw_treedict) : 'n/a').">") let dirname= s:NetrwTreeDir() if dirname =~ '/$' let dirname= dirname.newdir else - let dirname= s:NetrwTreeDir()."/".newdir + let dirname= dirname."/".newdir endif " call Decho("(NetrwBrowseChgDir:edit-a-file) dirname<".dirname.">") " call Decho("(NetrwBrowseChgDir:edit-a-file) tree listing") @@ -4364,9 +4524,16 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " the point where netrw actually edits the (local) file " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will + " no keepalt to support :e # to return to a directory listing if a:islocal " call Decho("(NetrwBrowseChgDir:edit-a-file) edit local file: exe e! ".fnameescape(dirname)) - exe "keepj keepalt e! ".fnameescape(dirname) + " some like c-^ to return to the last edited file + " others like c-^ to return to the netrw buffer + if exists("g:netrw_altfile") && g:netrw_altfile + exe "keepj keepalt e! ".fnameescape(dirname) + else + exe "keepj e! ".fnameescape(dirname) + endif call s:NetrwCursor() else " call Decho("(NetrwBrowseChgDir:edit-a-file) remote file: NetrwBrowse will edit it") @@ -4434,6 +4601,21 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) endif " call Decho("(NetrwBrowseChgDir:go-up) amiga: dirname<".dirname."> (go up one dir)") + elseif !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) + " windows + if a:islocal + let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') + if dirname == "" + let dirname= '/' + endif + else + let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') + endif + if dirname =~ '^\a:$' + let dirname= dirname.'/' + endif +" call Decho("(NetrwBrowseChgDir:go-up) windows: dirname<".dirname."> (go up one dir)") + else " unix or cygwin " call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and unix or cygwin') @@ -5006,11 +5188,14 @@ fun! s:NetrwLeftmouse(islocal) " call Dret("s:NetrwLeftmouse : detected a status bar leftmouse click") return endif - if v:mouse_col != col('.') - let @@= ykeep + " NOTE: following test is preventing leftmouse selection/deselection of directories and files in treelist mode (Dec 04, 2013) + " Windows are separated by vertical separator bars - but the mouse seems to be doing what it should when dragging that bar + " without this test. +" if v:mouse_col != col('.') +" let @@= ykeep " call Dret("s:NetrwLeftmouse : detected a vertical separator bar leftmouse click") - return - endif +" return +" endif if a:islocal if exists("b:netrw_curdir") @@ -5026,44 +5211,53 @@ fun! s:NetrwLeftmouse(islocal) endfun " --------------------------------------------------------------------- -" s:NetrwRightdrag: {{{2 -"DechoTabOn -fun! s:NetrwRightdrag(islocal) -" call Dfunc("s:NetrwRightdrag(islocal=".a:islocal.")") - if !exists("s:netrwdrag") - let s:netrwdrag = winnr() - call s:NetrwMarkFile(a:islocal,s:NetrwGetWord()) - if a:islocal - nno :call NetrwRightrelease(1) - else - nno :call NetrwRightrelease(0) - endif - endif -" call Dret("s:NetrwRightdrag : s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) +" s:NetrwSLeftmouse: marks the file under the cursor. May be dragged to select additional files {{{2 +fun! s:NetrwSLeftmouse(islocal) +" call Dfunc("s:NetrwSLeftmouse(islocal=".a:islocal.")") + + let s:ngw= s:NetrwGetWord() + call s:NetrwMarkFile(a:islocal,s:ngw) + +" call Dret("s:NetrwSLeftmouse") endfun " --------------------------------------------------------------------- -" s:NetrwRightrelease: {{{2 -fun! s:NetrwRightrelease(islocal) -" call Dfunc("s:NetrwRightrelease(islocal=".a:islocal.") s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) - if exists("s:netrwdrag") - nunmap - let tgt = s:NetrwGetWord() -" call Decho("target#1: ".tgt) - if tgt =~ '/$' && tgt !~ '^\./$' - let tgt = b:netrw_curdir."/".tgt +" s:NetrwSLeftdrag: invoked via a shift-leftmouse and dragging {{{2 +" Used to mark multiple files. +fun! s:NetrwSLeftdrag(islocal) +" call Dfunc("s:NetrwSLeftdrag(islocal=".a:islocal.")") + if !exists("s:netrwdrag") + let s:netrwdrag = winnr() + if a:islocal + nno :call NetrwSLeftrelease(1) else - let tgt= b:netrw_curdir + nno :call NetrwSLeftrelease(0) + endif + endif + let ngw = s:NetrwGetWord() + if !exists("s:ngw") || s:ngw != ngw + call s:NetrwMarkFile(a:islocal,ngw) + endif + let s:ngw= ngw +" call Dret("s:NetrwSLeftdrag : s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) +endfun + +" --------------------------------------------------------------------- +" s:NetrwSLeftrelease: terminates shift-leftmouse dragging {{{2 +fun! s:NetrwSLeftrelease(islocal) +" call Dfunc("s:NetrwSLeftrelease(islocal=".a:islocal.") s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) + if exists("s:netrwdrag") + nunmap + let ngw = s:NetrwGetWord() + if !exists("s:ngw") || s:ngw != ngw + call s:NetrwMarkFile(a:islocal,ngw) + endif + if exists("s:ngw") + unlet s:ngw endif -" call Decho("target#2: ".tgt) - call netrw#NetrwMakeTgt(tgt) - let curwin= winnr() - exe s:netrwdrag."wincmd w" - call s:NetrwMarkFileMove(a:islocal) - exe curwin."wincmd w" unlet s:netrwdrag endif -" call Dret("s:NetrwRightrelease") +" call Dret("s:NetrwSLeftrelease") endfun " --------------------------------------------------------------------- @@ -5205,7 +5399,11 @@ fun! s:NetrwMakeDir(usrhost) " requested new local directory is neither a pre-existing file or " directory, so make it! if exists("*mkdir") - call mkdir(fullnewdir,"p") + if has("unix") + call mkdir(fullnewdir,"p",xor(0777, system("umask"))) + else + call mkdir(fullnewdir,"p") + endif else let netrw_origdir= s:NetrwGetcwd(1) exe 'keepj lcd '.fnameescape(b:netrw_curdir) @@ -5467,8 +5665,13 @@ endfun " directories. Uses the local-buffer marked file list. " Returns 1=success (used by NetrwMarkFileMove()) " 0=failure -fun! s:NetrwMarkFileCopy(islocal) -" call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---').">") +fun! s:NetrwMarkFileCopy(islocal,...) +" call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---')."> a:0=".a:0) + + if !exists("b:netrw_curdir") + let b:netrw_curdir= getcwd() +" call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") + endif let curdir = b:netrw_curdir let curbufnr = bufnr("%") @@ -5495,8 +5698,45 @@ fun! s:NetrwMarkFileCopy(islocal) " call Dfunc("s:NetrwMarkFileMove : g:netrw_localcopycmd<".g:netrw_localcopycmd."> n/a!") return endif - let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"shellescape(b:netrw_curdir.\"/\".v:val)")) - let tgt = shellescape(s:netrwmftgt) + + " copy marked files while within the same directory (ie. allow renaming) + if simplify(s:netrwmftgt) == simplify(b:netrw_curdir) + if len(s:netrwmarkfilelist_{bufnr('%')}) == 1 + " only one marked file + let args = shellescape(b:netrw_curdir."/".s:netrwmarkfilelist_{bufnr('%')}[0]) + let oldname = s:netrwmarkfilelist_{bufnr('%')}[0] + elseif a:0 == 1 + " this happens when the next case was used to recursively call s:NetrwMarkFileCopy() + let args = shellescape(b:netrw_curdir."/".a:1) + let oldname = a:1 + else + " copy multiple marked files inside the same directory + let s:recursive= 1 + for oldname in s:netrwmarkfilelist_{bufnr("%")} + let ret= s:NetrwMarkFileCopy(a:islocal,oldname) + if ret == 0 + break + endif + endfor + unlet s:recursive + call s:NetrwUnmarkList(curbufnr,curdir) +" call Dret("s:NetrwMarkFileCopy ".ret) + return ret + endif + + call inputsave() + let newname= input("Copy ".oldname." to : ",oldname,"file") + call inputrestore() + if newname == "" +" call Dret("s:NetrwMarkFileCopy 0") + return 0 + endif + let args= shellescape(oldname) + let tgt = shellescape(s:netrwmftgt.'/'.newname) + else + let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"shellescape(b:netrw_curdir.\"/\".v:val)")) + let tgt = shellescape(s:netrwmftgt) + endif if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) let args= substitute(args,'/','\\','g') let tgt = substitute(tgt, '/','\\','g') @@ -5525,10 +5765,12 @@ fun! s:NetrwMarkFileCopy(islocal) keepj call s:NetrwUpload(s:netrwmarkfilelist_{bufnr('%')},s:netrwmftgt) elseif !a:islocal && s:netrwmftgt_islocal + " Copy marked files, remote directory to local directory " call Decho("copy from remote to local") keepj call netrw#NetrwObtain(a:islocal,s:netrwmarkfilelist_{bufnr('%')},s:netrwmftgt) elseif !a:islocal && !s:netrwmftgt_islocal + " Copy marked files, remote directory to remote directory " call Decho("copy from remote to remote") let curdir = getcwd() let tmpdir = s:GetTempfile("") @@ -5570,10 +5812,11 @@ fun! s:NetrwMarkFileCopy(islocal) " ------- " cleanup " ------- -" call Decho("cleanup") - - " remove markings from local buffer - call s:NetrwUnmarkList(curbufnr,curdir) +" call Decho("cleanup") + if !exists("s:recursive") + " remove markings from local buffer + call s:NetrwUnmarkList(curbufnr,curdir) + endif " refresh buffers if !s:netrwmftgt_islocal @@ -6213,7 +6456,7 @@ fun! s:NetrwMarkFileRegexp(islocal) sil keepj %s/\s\{2,}/\r/ge call histdel("/",-1) elseif g:netrw_liststyle == s:TREELIST - sil keepj %s/^| //e + exe 'sil keepj %s/^'.s:treedepthstring.' //e' sil! keepj g/^ .*$/d call histdel("/",-1) call histdel("/",-1) @@ -6520,63 +6763,74 @@ fun! s:NetrwMenu(domenu) if !exists("s:netrw_menu_enabled") && a:domenu " call Decho("initialize menu") let s:netrw_menu_enabled= 1 - exe 'sil! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help ' - exe 'sil! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' - exe 'sil! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory- -' - exe 'sil! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewerx x' + exe 'sil! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help ' + exe 'sil! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' + exe 'sil! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory- -' + exe 'sil! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewerx x' if g:netrw_dirhistmax > 0 exe 'sil! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directorymb mb' exe 'sil! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)u u' exe 'sil! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)U U' exe 'sil! menu '.g:NetrwMenuPriority.'.8.6 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Listqb qb' else - exe 'sil! menu '.g:NetrwMenuPriority.'.8 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History :echo "(disabled)"'."\" + exe 'sil! menu '.g:NetrwMenuPriority.'.8 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History :echo "(disabled)"'."\" endif - exe 'sil! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List'." \'" - exe 'sil! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ SequenceS S' - exe 'sil! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files'."gh gh" - exe 'sil! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing'." \" - exe 'sil! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options:NetrwSettings '.":NetrwSettings\" - exe 'sil! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/DirectoryD D' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Create\ New\ File% %' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window '."\" - exe 'sil! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directoryp p' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ WindowP P' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Windowo o' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Windowv v' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore ' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only):Explore\ */ :Explore */' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs):Explore\ **/ :Explore **/' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (curdir\ only):Explore\ *// :Explore *//' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (+subdirs):Explore\ **// :Explore **//' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match:Nexplore :Nexplore' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match:Pexplore :Pexplore' - exe 'sil! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectoryd d' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Filemf mf' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexpmr mr' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Controla a' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Targetmc mc' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.DeleteD D' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diffmd md' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Editme me' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmdmx mx' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Targetmm mm' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.ObtainO O' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Printmp mp' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.ReplaceR R' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Targetmt mt' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.TagmT mT' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompressmz mz' - exe 'sil! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ FileO O' - exe 'sil! menu '.g:NetrwMenuPriority.'.16.1 '.g:NetrwTopLvlMenu.'Style.Listing\ Style\ (thin-long-wide-tree)i i' - exe 'sil! menu '.g:NetrwMenuPriority.'.16.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Showa a' - exe 'sil! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order'."r r" - exe 'sil! menu '.g:NetrwMenuPriority.'.16.4 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method\ (name-time-size)s s' - exe 'sil! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/DirectoryR R' - exe 'sil! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directoryc c' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Horizontal\ Splito o' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Vertical\ Splitv v' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.New\ Tabt t' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Previewp p' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List'." \'" + exe 'sil! menu '.g:NetrwMenuPriority.'.9.6 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ SequenceS S' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.7 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files'."gh gh" + exe 'sil! menu '.g:NetrwMenuPriority.'.9.8 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing'." \" + exe 'sil! menu '.g:NetrwMenuPriority.'.9.9 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options:NetrwSettings '.":NetrwSettings\" + exe 'sil! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/DirectoryD D' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Create\ New\ File% %' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window '."\" + exe 'sil! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directoryp p' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ WindowP P' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Windowo o' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Windowv v' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore ' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only):Explore\ */ :Explore */' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs):Explore\ **/ :Explore **/' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (curdir\ only):Explore\ *// :Explore *//' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (+subdirs):Explore\ **// :Explore **//' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match:Nexplore :Nexplore' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match:Pexplore :Pexplore' + exe 'sil! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectoryd d' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Filemf mf' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexpmr mr' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Controla a' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Targetmc mc' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.DeleteD D' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diffmd md' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Editme me' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmdmx mx' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Targetmm mm' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.ObtainO O' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Printmp mp' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.ReplaceR R' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Targetmt mt' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.TagmT mT' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompressmz mz' + exe 'sil! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ FileO O' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.thini :let w:netrw_liststyle=0' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.longi :let w:netrw_liststyle=1' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.widei :let w:netrw_liststyle=2' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.treei :let w:netrw_liststyle=3' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.1 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Show\ Alla :let g:netrw_hide=0' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.3 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Normala :let g:netrw_hide=1' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Hidden\ Onlya :let g:netrw_hide=2' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order'."r r" + exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.1 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Names :let g:netrw_sort_by="name"' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.2 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Times :let g:netrw_sort_by="time"' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.3 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Sizes :let g:netrw_sort_by="size"' + exe 'sil! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/DirectoryR R' + exe 'sil! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directoryc c' let s:netrw_menucnt= 28 call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4, 8.2.x - call s:NetrwTgtMenu() " let bookmarks and history be easy targets + call s:NetrwTgtMenu() " let bookmarks and history be easy targets elseif !a:domenu let s:netrwcnt = 0 @@ -6625,93 +6879,100 @@ endfun " choice = 2 : didn't save modified file, opened window " choice = 3 : cancel open fun! s:NetrwPrevWinOpen(islocal) -" call Dfunc("NetrwPrevWinOpen(islocal=".a:islocal.")") +" call Dfunc("s:NetrwPrevWinOpen(islocal=".a:islocal.")") let ykeep= @@ " grab a copy of the b:netrw_curdir to pass it along to newly split windows let curdir = b:netrw_curdir " get last window number and the word currently under the cursor + let origwin = winnr() let lastwinnr = winnr("$") let curword = s:NetrwGetWord() let choice = 0 -" call Decho("lastwinnr=".lastwinnr." curword<".curword.">") + let s:treedir = s:NetrwTreeDir() +" call Decho("(s:NetrwPrevWinOpen) winnr($)#".lastwinnr." curword<".curword.">") - let didsplit = 0 + let didsplit = 0 if lastwinnr == 1 " if only one window, open a new one first -" call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")") +" call Decho("(s:NetrwPrevWinOpen) only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")") if g:netrw_preview let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize -" call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s") +" call Decho("(s:NetrwPrevWinOpen) exe ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s") exe (g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s" else let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize -" call Decho("exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s") +" call Decho("(s:NetrwPrevWinOpen) exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s") exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" endif - let didsplit = 1 + let didsplit = 1 +" call Decho("(s:NetrwPrevWinOpen) did split") else keepj call s:SaveBufVars() -" call Decho("wincmd p") + let eikeep= &ei + set ei=all wincmd p +" call Decho("(s:NetrwPrevWinOpen) wincmd p (now in win#".winnr().")") + + " prevwinnr: the window number of the "prev" window + " prevbufnr: the buffer number of the buffer in the "prev" window + " bnrcnt : the qty of windows open on the "prev" buffer + let prevwinnr = winnr() + let prevbufnr = bufnr("%") + let prevbufname = bufname("%") + let prevmod = &mod + let bnrcnt = 0 keepj call s:RestoreBufVars() - " if the previous window's buffer has been changed (is modified), +" call Decho("(s:NetrwPrevWinOpen) after wincmd p: win#".winnr()." win($)#".winnr("$")." origwin#".origwin." &mod=".&mod." bufname(%)<".bufname("%")."> prevbufnr=".prevbufnr) + + " if the previous window's buffer has been changed (ie. its modified flag is set), " and it doesn't appear in any other extant window, then ask the " user if s/he wants to abandon modifications therein. - let bnr = winbufnr(0) - let bnrcnt = 0 - if &mod -" call Decho("detected: prev window's buffer has been modified: bnr=".bnr." winnr#".winnr()) - let eikeep= &ei - set ei=all - windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif - exe bnr."wincmd p" - let &ei= eikeep -" call Decho("bnr=".bnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr#".winnr()) - if bnrcnt == 1 - let bufname = bufname(winbufnr(winnr())) - let choice = confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel") -" call Decho("bufname<".bufname."> choice=".choice." winnr#".winnr()) + if prevmod +" call Decho("(s:NetrwPrevWinOpen) detected that prev window's buffer has been modified: prevbufnr=".prevbufnr." winnr()#".winnr()) + windo if winbufnr(0) == prevbufnr | let bnrcnt=bnrcnt+1 | endif +" call Decho("(s:NetrwPrevWinOpen) prevbufnr=".prevbufnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr()=".winnr()." prevwinnr#".prevwinnr) + exe prevwinnr."wincmd w" + + if bnrcnt == 1 && &hidden == 0 + " only one copy of the modified buffer in a window, and + " hidden not set, so overwriting will lose the modified file. Ask first... + let choice = confirm("Save modified buffer<".prevbufname."> first?","&Yes\n&No\n&Cancel") +" call Decho("(NetrwPrevWinOpen) prevbufname<".prevbufname."> choice=".choice." current-winnr#".winnr()) + let &ei= eikeep if choice == 1 " Yes -- write file & then browse let v:errmsg= "" sil w if v:errmsg != "" - call netrw#ErrorMsg(s:ERROR,"unable to write <".bufname.">!",30) - if didsplit - q - else - wincmd p - endif - let @@= ykeep -" call Dret("NetrwPrevWinOpen ".choice." : unable to write <".bufname.">") + call netrw#ErrorMsg(s:ERROR,"unable to write <".prevbufname.">!",30) + exe origwin."wincmd w" + let &ei = eikeep + let @@ = ykeep +" call Dret("s:NetrwPrevWinOpen ".choice." : unable to write <".prevbufname.">") return choice endif elseif choice == 2 " No -- don't worry about changed file, just browse anyway -" call Decho("(NetrwPrevWinOpen) setl nomod") - setl nomod -" call Decho("(NetrwPrevWinOpen) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") - keepj call netrw#ErrorMsg(s:WARNING,bufname." changes to ".bufname." abandoned",31) - wincmd p +" call Decho("(s:NetrwPrevWinOpen) don't worry about chgd file, just browse anyway (winnr($)#".winnr("$").")") + echomsg "**note** changes to ".prevbufname." abandoned" else " Cancel -- don't do this - if didsplit - q - else - wincmd p - endif - let @@= ykeep -" call Dret("NetrwPrevWinOpen ".choice." : cancelled") +" call Decho("(s:NetrwPrevWinOpen) cancel, don't browse, switch to win#".origwin) + exe origwin."wincmd w" + let &ei= eikeep + let @@ = ykeep +" call Dret("s:NetrwPrevWinOpen ".choice." : cancelled") return choice endif endif endif + let &ei= eikeep endif " restore b:netrw_curdir (window split/enew may have lost it) @@ -6724,7 +6985,7 @@ fun! s:NetrwPrevWinOpen(islocal) endif endif let @@= ykeep -" call Dret("NetrwPrevWinOpen ".choice) +" call Dret("s:NetrwPrevWinOpen ".choice) return choice endfun @@ -7187,13 +7448,29 @@ fun! s:NetrwSplit(mode) elseif a:mode == 4 " local and t let cursorword = s:NetrwGetWord() + let eikeep = &ei + let netrw_winnr = winnr() + let netrw_line = line(".") + let netrw_col = virtcol(".") + keepj norm! H0 + let netrw_hline = line(".") + set ei=all + exe "keepj norm! ".netrw_hline."G0z\" + exe "keepj norm! ".netrw_line."G0".netrw_col."\" + let &ei= eikeep let netrw_curdir= s:NetrwTreeDir() " call Decho("tabnew") tabnew - let b:netrw_curdir= netrw_curdir - let s:didsplit= 1 + let b:netrw_curdir = netrw_curdir + let s:didsplit = 1 keepj call s:RestoreWinVars() keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,cursorword)) + if &ft == "netrw" + set ei=all + exe "keepj norm! ".netrw_hline."G0z\" + exe "keepj norm! ".netrw_line."G0".netrw_col."\" + let &ei= eikeep + endif unlet s:didsplit elseif a:mode == 5 @@ -7268,60 +7545,57 @@ endfun " s:NetrwTreeDir: determine tree directory given current cursor position {{{2 " (full path directory with trailing slash returned) fun! s:NetrwTreeDir() -" call Dfunc("NetrwTreeDir() curline#".line(".")."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") +" call Dfunc("s:NetrwTreeDir() getline(".line(".").")"."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft) - let treedir= b:netrw_curdir -" call Decho("(NetrwTreeDir) set initial treedir<".treedir.">") + if exists("s:treedir") + " s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early + let treedir= s:treedir + unlet s:treedir +" call Dret("s:NetrwTreeDir ".treedir) + return treedir + endif + if !exists("b:netrw_curdir") || b:netrw_curdir == "" + let b:netrw_curdir= getcwd() + endif + let treedir = b:netrw_curdir +" call Decho("(s:NetrwTreeDir) set initial treedir<".treedir.">") let s:treecurpos= netrw#NetrwSavePosn() if w:netrw_liststyle == s:TREELIST -" call Decho("(NetrwTreeDir) w:netrw_liststyle is TREELIST:") -" call Decho("(NetrwTreeDir) line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") +" call Decho("(s:NetrwTreeDir) w:netrw_liststyle is TREELIST:") +" call Decho("(s:NetrwTreeDir) line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") " extract tree directory if on a line specifying a subdirectory (ie. ends with "/") if getline('.') =~ '/$' - let treedir= substitute(getline('.'),'^\%(| \)*\([^|].\{-}\)$','\1','e') +" call Decho("extract tree subdirectory from current line") + let treedir= substitute(getline('.'),'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') +" call Decho("(s:NetrwTreeDir) treedir<".treedir.">") else +" call Decho("(s:NetrwTreeDir) do not extract tree subdirectory from current line and set treedir to empty") let treedir= "" endif -" call Decho("(NetrwTreeDir) treedir<".treedir.">") " detect user attempting to close treeroot - if getline('.') !~ '|' && getline('.') != '..' -" call Decho("user attempted to close treeroot") +" call Decho("(s:NetrwTreeDir) win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") +" call Decho("(s:NetrwTreeDir) getline(".line(".").")<".getline('.').'> '.((getline('.') =~ '^'.s:treedepthstring)? '=~' : '!~').' ^'.s:treedepthstring) + if getline('.') !~ '^'.s:treedepthstring && getline('.') != '..' +" call Decho("user may have attempted to close treeroot") " now force a refresh -" call Decho("(NetrwTreeDir) clear buffer<".expand("%")."> with :%d") +" call Decho("(s:NetrwTreeDir) clear buffer<".expand("%")."> with :%d") sil! keepj %d -" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") +" call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") return b:netrw_curdir +" else " Decho +" call Decho("user did not attempt to close treeroot") endif - " elide all non-depth information - let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e') -" call Decho("(NetrwTreeDir) depth<".depth."> 1st subst (non-depth info removed)") - - " elide first depth - let depth = substitute(depth,'^| ','','') -" call Decho("(NetrwTreeDir) depth<".depth."> 2nd subst (first depth removed)") - - " construct treedir by searching backwards at correct depth -" call Decho("(NetrwTreeDir) constructing treedir<".treedir."> depth<".depth.">") - while depth != "" && search('^'.depth.'[^|].\{-}/$','bW') - let dirname= substitute(getline('.'),'^\(| \)*','','e') - let treedir= dirname.treedir - let depth = substitute(depth,'^| ','','') -" call Decho("(NetrwTreeDir) constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") - endwhile - if w:netrw_treetop =~ '/$' - let treedir= w:netrw_treetop.treedir - else - let treedir= w:netrw_treetop.'/'.treedir - endif -" call Decho("(NetrwTreeDir) bufnr(.)=".bufnr("%")." line($)=".line("$")." line(.)=".line(".")) + let treedir= s:NetrwTreePath(w:netrw_treetop) endif + + " sanity maintenance: keep those //s away... let treedir= substitute(treedir,'//$','/','') -" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") +" call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") return treedir endfun @@ -7358,7 +7632,7 @@ fun! s:NetrwTreeDisplay(dir,depth) endif " display subtrees (if any) - let depth= "| ".a:depth + let depth= s:treedepthstring.a:depth " call Decho("display subtrees with depth<".depth."> and current leaves") for entry in w:netrw_treedict[a:dir] @@ -7375,6 +7649,7 @@ fun! s:NetrwTreeDisplay(dir,depth) sil! keepj call setline(line("$")+1,depth.entry) endif endfor + " call Dret("NetrwTreeDisplay") endfun @@ -7383,17 +7658,18 @@ endfun fun! s:NetrwTreeListing(dirname) if w:netrw_liststyle == s:TREELIST " call Dfunc("NetrwTreeListing() bufname<".expand("%").">") -" call Decho("curdir<".a:dirname.">") -" call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exit")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit")) +" call Decho("(s:NetrwTreeListing) curdir<".a:dirname.">") +" call Decho("(s:NetrwTreeListing) win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exist")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit")) +" call Decho("(s:NetrwTreeListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") " update the treetop -" call Decho("update the treetop") +" call Decho("(s:NetrwTreeListing) update the treetop") if !exists("w:netrw_treetop") let w:netrw_treetop= a:dirname -" call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)") +" call Decho("(s:NetrwTreeListing) w:netrw_treetop<".w:netrw_treetop."> (reusing)") elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) let w:netrw_treetop= a:dirname -" call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)") +" call Decho("(s:NetrwTreeListing) w:netrw_treetop<".w:netrw_treetop."> (went up)") endif " insure that we have at least an empty treedict @@ -7402,11 +7678,11 @@ fun! s:NetrwTreeListing(dirname) endif " update the directory listing for the current directory -" call Decho("updating dictionary with ".a:dirname.":[..directory listing..]") -" call Decho("bannercnt=".w:netrw_bannercnt." line($)=".line("$")) +" call Decho("(s:NetrwTreeListing) updating dictionary with ".a:dirname.":[..directory listing..]") +" call Decho("(s:NetrwTreeListing) w:netrw_bannercnt=".w:netrw_bannercnt." line($)=".line("$")) exe "sil! keepj ".w:netrw_bannercnt.',$g@^\.\.\=/$@d' let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$")) -" call Decho("w:treedict[".a:dirname."]= ".string(w:netrw_treedict[a:dirname])) +" call Decho("(s:NetrwTreeListing) w:treedict[".a:dirname."]= ".string(w:netrw_treedict[a:dirname])) exe "sil! keepj ".w:netrw_bannercnt.",$d" " if past banner, record word @@ -7415,10 +7691,20 @@ fun! s:NetrwTreeListing(dirname) else let fname= "" endif -" call Decho("fname<".fname.">") +" call Decho("(s:NetrwTreeListing) fname<".fname.">") +" call Decho("(s:NetrwTreeListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") " display from treetop on down keepj call s:NetrwTreeDisplay(w:netrw_treetop,"") +" call Decho("s:NetrwTreeDisplay) setl noma nomod ro") + + " remove any blank line remaining as line#1 (happens in treelisting mode with banner suppressed) + while getline(1) =~ '^\s*$' && byte2line(1) > 0 +" call Decho("(s:PerformListing) deleting blank line") + 1d + endwhile + + setl noma nomod ro " call Dret("NetrwTreeListing : bufname<".expand("%").">") return @@ -7478,25 +7764,71 @@ fun! s:NetrwWideListing() sil! let @*= keepregstar exe "sil! keepj ".w:netrw_bannercnt.',$s/\s\+$//e' keepj call histdel("/",-1) + exe "nmap w /^\\\\|\\s\\s\\zs\\S/\" + exe "nmap b ?^\\\\|\\s\\s\\zs\\S?\" " call Decho("NetrwWideListing) setl noma nomod ro") setl noma nomod ro " call Decho("(NetrwWideListing) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") " call Dret("NetrwWideListing") return + else + if hasmapto("w","n") + sil! nunmap w + endif + if hasmapto("b","n") + sil! nunmap b + endif endif endfun +" --------------------------------------------------------------------- +" s:NetrwTreePath: returns path to current file in tree listing {{{2 +" Normally, treetop is w:netrw_treetop, but a +" user of this function ( netrw#NetrwSetTreetop() ) +" wipes that out prior to calling this function +fun! s:NetrwTreePath(treetop) +" call Dfunc("s:NetrwTreePath()") + let depth = substitute(getline('.'),'^\(\%('.s:treedepthstring.'\)*\)[^'.s:treedepthstring.'].\{-}$','\1','e') + let depth = substitute(depth,'^'.s:treedepthstring,'','') +" call Decho("(s:NetrwTreePath) depth<".depth."> 2nd subst (first depth removed)") + if getline('.') =~ '/$' +" call Decho("extract tree directory from current line") + let treedir= substitute(getline('.'),'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') +" call Decho("(s:NetrwTreePath) treedir<".treedir.">") + else +" call Decho("(s:NetrwTreePath) do not extract tree directory from current line and set treedir to empty") + let treedir= "" + endif + " construct treedir by searching backwards at correct depth +" call Decho("(s:NetrwTreePath) initial treedir<".treedir."> depth<".depth.">") + while depth != "" && search('^'.depth.'[^'.s:treedepthstring.'].\{-}/$','bW') + let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') + let treedir= dirname.treedir + let depth = substitute(depth,'^'.s:treedepthstring,'','') +" call Decho("(s:NetrwTreePath) constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") + endwhile + if a:treetop =~ '/$' + let treedir= a:treetop.treedir + else + let treedir= a:treetop.'/'.treedir + endif + let treedir= substitute(treedir,'//$','/','') +" call Dret("s:NetrwTreePath <".treedir.">") + return treedir +endfun + " --------------------------------------------------------------------- " s:PerformListing: {{{2 fun! s:PerformListing(islocal) " call Dfunc("s:PerformListing(islocal=".a:islocal.") bufnr(%)=".bufnr("%")."<".bufname("%").">") +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (enter)") " set up syntax highlighting {{{3 -" call Decho("(PerformListing) set up syntax highlighting") +" call Decho("(s:PerformListing) set up syntax highlighting") if has("syntax") if !exists("g:syntax_on") || !g:syntax_on -" call Decho("(PerformListing) but g:syntax_on".(exists("g:syntax_on")? "=".g:syntax_on : "")) +" call Decho("(s:PerformListing) but g:syntax_on".(exists("g:syntax_on")? "=".g:syntax_on : "")) setl ft= elseif &ft != "netrw" setl ft=netrw @@ -7505,16 +7837,16 @@ fun! s:PerformListing(islocal) keepj call s:NetrwSafeOptions() set noro ma -" call Decho("(PerformListing) setl noro ma bh=".&bh) +" call Decho("(s:PerformListing) setl noro ma bh=".&bh) " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho -" call Decho("(PerformListing) (netrw) Processing your browsing request...") +" call Decho("(s:PerformListing) (netrw) Processing your browsing request...") " endif " Decho " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')) if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") " force a refresh for tree listings -" call Decho("(PerformListing) force refresh for treelisting: clear buffer<".expand("%")."> with :%d") +" call Decho("(s:PerformListing) force refresh for treelisting: clear buffer<".expand("%")."> with :%d") sil! keepj %d endif @@ -7523,10 +7855,14 @@ fun! s:PerformListing(islocal) " Set up the banner {{{3 if g:netrw_banner -" call Decho("(PerformListing) set up banner") +" call Decho("(s:PerformListing) set up banner") keepj call setline(1,'" ============================================================================') keepj call setline(2,'" Netrw Directory Listing (netrw '.g:loaded_netrw.')') - keepj call setline(3,'" '.b:netrw_curdir) + if exists("g:netrw_bannerbackslash") && g:netrw_bannerbackslash + keepj call setline(3,'" '.substitute(b:netrw_curdir,'/','\\','g')) + else + keepj call setline(3,'" '.b:netrw_curdir) + endif let w:netrw_bannercnt= 3 keepj exe "sil! keepj ".w:netrw_bannercnt else @@ -7541,26 +7877,28 @@ fun! s:PerformListing(islocal) " Sorted by... {{{3 if g:netrw_banner -" call Decho("(PerformListing) handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") +" call Decho("(s:PerformListing) handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") if g:netrw_sort_by =~ "^n" -" call Decho("(PerformListing) directories will be sorted by name") +" call Decho("(s:PerformListing) directories will be sorted by name") " sorted by name keepj put ='\" Sorted by '.sortby keepj put ='\" Sort sequence: '.g:netrw_sort_sequence let w:netrw_bannercnt= w:netrw_bannercnt + 2 else -" call Decho("(PerformListing) directories will be sorted by size or time") +" call Decho("(s:PerformListing) directories will be sorted by size or time") " sorted by size or date keepj put ='\" Sorted by '.sortby let w:netrw_bannercnt= w:netrw_bannercnt + 1 endif exe "sil! keepj ".w:netrw_bannercnt +" else " Decho +" call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") endif " show copy/move target, if any if g:netrw_banner if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") -" call Decho("(PerformListing) show copy/move target<".s:netrwmftgt.">") +" call Decho("(s:PerformListing) show copy/move target<".s:netrwmftgt.">") keepj put ='' if s:netrwmftgt_islocal sil! keepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (local)') @@ -7569,14 +7907,14 @@ fun! s:PerformListing(islocal) endif let w:netrw_bannercnt= w:netrw_bannercnt + 1 else -" call Decho("(PerformListing) s:netrwmftgt does not exist, don't make Copy/Move Tgt") +" call Decho("(s:PerformListing) s:netrwmftgt does not exist, don't make Copy/Move Tgt") endif exe "sil! keepj ".w:netrw_bannercnt endif " Hiding... -or- Showing... {{{3 if g:netrw_banner -" call Decho("(PerformListing) handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") +" call Decho("(s:PerformListing) handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") if g:netrw_list_hide != "" && g:netrw_hide if g:netrw_hide == 1 keepj put ='\" Hiding: '.g:netrw_list_hide @@ -7589,43 +7927,48 @@ fun! s:PerformListing(islocal) keepj put ='\" Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:exec' keepj put ='\" ============================================================================' let w:netrw_bannercnt= w:netrw_bannercnt + 2 +" else " Decho +" call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") endif " bannercnt should index the line just after the banner if g:netrw_banner let w:netrw_bannercnt= w:netrw_bannercnt + 1 exe "sil! keepj ".w:netrw_bannercnt -" call Decho("(PerformListing) bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) +" call Decho("(s:PerformListing) w:netrw_bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) +" else " Decho +" call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") endif " get list of files -" call Decho("(PerformListing) Get list of files - islocal=".a:islocal) +" call Decho("(s:PerformListing) Get list of files - islocal=".a:islocal) if a:islocal keepj call s:LocalListing() else " remote keepj call s:NetrwRemoteListing() endif -" call Decho("(PerformListing) g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") +" call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") +" call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") " manipulate the directory listing (hide, sort) {{{3 if !exists("w:netrw_bannercnt") let w:netrw_bannercnt= 0 endif if !g:netrw_banner || line("$") >= w:netrw_bannercnt -" call Decho("(PerformListing) manipulate directory listing (hide)") -" call Decho("(PerformListing) g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") +" call Decho("(s:PerformListing) manipulate directory listing (hide)") +" call Decho("(s:PerformListing) g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") if g:netrw_hide && g:netrw_list_hide != "" keepj call s:NetrwListHide() endif if !g:netrw_banner || line("$") >= w:netrw_bannercnt -" call Decho("(PerformListing) manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") +" call Decho("(s:PerformListing) manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") if g:netrw_sort_by =~ "^n" " sort by name keepj call s:NetrwSetSort() if !g:netrw_banner || w:netrw_bannercnt < line("$") -" call Decho("(PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") +" call Decho("(s:PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") if g:netrw_sort_direction =~ 'n' " normal direction sorting exe 'sil keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options @@ -7635,13 +7978,13 @@ fun! s:PerformListing(islocal) endif endif " remove priority pattern prefix -" call Decho("(PerformListing) remove priority pattern prefix") +" call Decho("(s:PerformListing) remove priority pattern prefix") exe 'sil! keepj '.w:netrw_bannercnt.',$s/^\d\{3}'.g:netrw_sepchr.'//e' keepj call histdel("/",-1) elseif a:islocal if !g:netrw_banner || w:netrw_bannercnt < line("$") -" call Decho("(PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction) +" call Decho("(s:PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction) if g:netrw_sort_direction =~ 'n' " call Decho('exe sil keepjumps '.w:netrw_bannercnt.',$sort') exe 'sil! keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options @@ -7655,47 +7998,57 @@ fun! s:PerformListing(islocal) endif elseif g:netrw_sort_direction =~ 'r' -" call Decho('reverse the sorted listing') +" call Decho('(s:PerformListing) reverse the sorted listing') if !g:netrw_banner || w:netrw_bannercnt < line('$') exe 'sil! keepj '.w:netrw_bannercnt.',$g/^/m '.w:netrw_bannercnt call histdel("/",-1) endif endif endif +" call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") " convert to wide/tree listing {{{3 -" call Decho("(PerformListing) modify display if wide/tree listing style") +" call Decho("(s:PerformListing) modify display if wide/tree listing style") +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#1)") keepj call s:NetrwWideListing() +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#2)") keepj call s:NetrwTreeListing(b:netrw_curdir) +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#3)") if exists("w:netrw_bannercnt") && (line("$") > w:netrw_bannercnt || !g:netrw_banner) " place cursor on the top-left corner of the file listing -" call Decho("(PerformListing) place cursor on top-left corner of file listing") +" call Decho("(s:PerformListing) place cursor on top-left corner of file listing") exe 'sil! keepj '.w:netrw_bannercnt sil! keepj norm! 0 endif " record previous current directory let w:netrw_prvdir= b:netrw_curdir -" call Decho("(PerformListing) record netrw_prvdir<".w:netrw_prvdir.">") +" call Decho("(s:PerformListing) record netrw_prvdir<".w:netrw_prvdir.">") " save certain window-oriented variables into buffer-oriented variables {{{3 +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#4)") keepj call s:SetBufWinVars() +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#5)") keepj call s:NetrwOptionRestore("w:") +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#6)") " set display to netrw display settings -" call Decho("(PerformListing) set display to netrw display settings (".g:netrw_bufsettings.")") +" call Decho("(s:PerformListing) set display to netrw display settings (".g:netrw_bufsettings.")") exe "setl ".g:netrw_bufsettings +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#7)") if g:netrw_liststyle == s:LONGLIST -" call Decho("(PerformListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) +" call Decho("(s:PerformListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) exe "setl ts=".(g:netrw_maxfilenamelen+1) endif - if exists("s:treecurpos") + if exists("s:treecurpos") +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#8)") keepj call netrw#NetrwRestorePosn(s:treecurpos) unlet s:treecurpos endif +" call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (return)") " call Dret("s:PerformListing : curpos<".string(getpos(".")).">") endfun @@ -7780,11 +8133,11 @@ fun! s:NetrwRemoteListing() endif " (remote handling sanity check) if exists("b:netrw_method") -" call Decho("setting w:netrw_method<".b:netrw_method.">") +" call Decho("setting w:netrw_method to b:netrw_method<".b:netrw_method.">") let w:netrw_method= b:netrw_method endif - if s:method == "ftp" + if s:method == "ftp" || s:method == "sftp" " use ftp to get remote file listing {{{3 " call Decho("use ftp to get remote file listing") let s:method = "ftp" @@ -7811,15 +8164,14 @@ fun! s:NetrwRemoteListing() sil! keepj %s/\r$//e keepj call histdel("/",-1) - " if there's no ../ listed, then put ./ and ../ in + " if there's no ../ listed, then put ../ in let line1= line(".") exe "sil! keepj ".w:netrw_bannercnt let line2= search('\.\.\/\%(\s\|$\)','cnW') " call Decho("search(".'\.\.\/\%(\s\|$\)'."','cnW')=".line2." w:netrw_bannercnt=".w:netrw_bannercnt) if line2 == 0 -" call Decho("netrw is putting ./ and ../ into listing") +" call Decho("netrw is putting ../ into listing") sil! keepj put='../' - sil! keepj put='./' endif exe "sil! keepj ".line1 sil! keepj norm! 0 @@ -7888,13 +8240,12 @@ fun! s:NetrwRemoteListing() while getline('.') =~ g:netrw_ftp_browse_reject sil! keepj d endwhile - " if there's no ../ listed, then put ./ and ../ in + " if there's no ../ listed, then put ../ in let line1= line(".") sil! keepj 1 sil! keepj call search('^\.\.\/\%(\s\|$\)','W') let line2= line(".") if line2 == 0 - exe 'sil! keepj '.w:netrw_bannercnt."put='./'" if b:netrw_curdir != '/' exe 'sil! keepj '.w:netrw_bannercnt."put='../'" endif @@ -8092,21 +8443,31 @@ endfun " and reverse sorts will be requested of the server but not otherwise " enforced here. fun! s:NetrwRemoteFtpCmd(path,listcmd) -" call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method) -" call Decho("line($)=".line("$")." bannercnt=".w:netrw_bannercnt) +" call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) w:netrw_method=".(exists("w:netrw_method")? w:netrw_method : (exists("b:netrw_method")? b:netrw_method : "???"))) +" call Decho("line($)=".line("$")." w:netrw_bannercnt=".w:netrw_bannercnt) + " sanity check: {{{3 + if !exists("w:netrw_method") + if exists("b:netrw_method") + let w:netrw_method= b:netrw_method + else + call netrw#ErrorMsg(2,"(s:NetrwRemoteFtpCmd) internal netrw error",93) +" call Dret("NetrwRemoteFtpCmd") + return + endif + endif - " because WinXX ftp uses unix style input + " WinXX ftp uses unix style input, so set ff to unix " {{{3 let ffkeep= &ff setl ma ff=unix noro " call Decho("setl ma ff=unix noro") - " clear off any older non-banner lines + " clear off any older non-banner lines " {{{3 " note that w:netrw_bannercnt indexes the line after the banner " call Decho('exe sil! keepjumps '.w:netrw_bannercnt.",$d (clear off old non-banner lines)") exe "sil! keepjumps ".w:netrw_bannercnt.",$d" "......................................... - if w:netrw_method == 2 || w:netrw_method == 5 + if w:netrw_method == 2 || w:netrw_method == 5 " {{{3 " ftp + <.netrc>: Method #2 if a:path != "" keepj put ='cd \"'.a:path.'\"' @@ -8125,8 +8486,8 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) exe s:netrw_silentxfer." keepj ".w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) endif - "......................................... - elseif w:netrw_method == 3 + "......................................... + elseif w:netrw_method == 3 " {{{3 " ftp + machine,id,passwd,filename: Method #3 setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" @@ -8169,12 +8530,24 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) exe s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options - "......................................... - else - keepj call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",23) + "......................................... + elseif w:netrw_method == 9 " {{{3 + " sftp username@machine: Method #9 + " s:netrw_sftp_cmd + setl ff=unix +" call Decho("COMBAK: still working on sftp remote listing") + + " restore settings + let &ff= ffkeep +" call Dret("NetrwRemoteFtpCmd") + return + + "......................................... + else " {{{3 + keepj call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . bufname("%") . ">",23) endif - " cleanup for Windows + " cleanup for Windows " {{{3 if has("win32") || has("win95") || has("win64") || has("win16") sil! keepj %s/\r$//e keepj call histdel("/",-1) @@ -8191,7 +8564,7 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) endif endif - " ftp's listing doesn't seem to include ./ or ../ + " ftp's listing doesn't seem to include ./ or ../ " {{{3 if !search('^\.\/$\|\s\.\/$','wn') exe 'keepj '.w:netrw_bannercnt keepj put ='./' @@ -8201,7 +8574,7 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) keepj put ='../' endif - " restore settings + " restore settings " {{{3 let &ff= ffkeep " call Dret("NetrwRemoteFtpCmd") endfun @@ -8345,23 +8718,31 @@ fun! netrw#LocalBrowseCheck(dirname) " would hit when re-entering netrw windows, creating unexpected " refreshes (and would do so in the middle of NetrwSaveOptions(), too) " call Decho("(LocalBrowseCheck) isdir<".a:dirname.">=".isdirectory(a:dirname).((exists("s:treeforceredraw")? " treeforceredraw" : ""))) -" call Dredir("LocalBrowseCheck","ls!")|redraw!|sleep 3 +" call Decho("(LocalBrowseCheck) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) +" call Dredir("(LocalBrowseCheck) ls!","ls!") let ykeep= @@ if isdirectory(a:dirname) -" call Decho("(LocalBrowseCheck) ft<".&ft."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$")." ft<".&ft."> g:netrw_fastbrowse=".g:netrw_fastbrowse) +" call Decho("(LocalBrowseCheck) is-directory ft<".&ft."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$")." ft<".&ft."> g:netrw_fastbrowse=".g:netrw_fastbrowse) let svposn= netrw#NetrwSavePosn() if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname) || g:netrw_fastbrowse <= 1 +" call Decho("(LocalBrowseCheck) case 1 (ft!=netrw)") sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) keepalt call netrw#NetrwRestorePosn(svposn) + elseif &ft == "netrw" && line("$") == 1 +" call Decho("(LocalBrowseCheck) case 2 (ft==netrw)") sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) keepalt call netrw#NetrwRestorePosn(svposn) + elseif exists("s:treeforceredraw") +" call Decho("(LocalBrowseCheck) case 3 (treeforceredraw)") unlet s:treeforceredraw sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) keepalt call netrw#NetrwRestorePosn(svposn) endif + endif + " following code wipes out currently unused netrw buffers " IF g:netrw_fastbrowse is zero (ie. slow browsing selected) " AND IF the listing style is not a tree listing @@ -8376,6 +8757,7 @@ fun! netrw#LocalBrowseCheck(dirname) endwhile endif let @@= ykeep +" call Decho("(LocalBrowseCheck) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " not a directory, ignore it endfun @@ -8388,17 +8770,20 @@ fun! s:LocalListing() " if exists("b:netrw_curdir") |call Decho('(LocalListing) b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("(LocalListing) b:netrw_curdir doesn't exist") |endif " if exists("g:netrw_sort_by")|call Decho('(LocalListing) g:netrw_sort_by<'.g:netrw_sort_by.">")|else|call Decho("(LocalListing) g:netrw_sort_by doesn't exist")|endif +" call Decho("(s:LocalListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") " get the list of files contained in the current directory let dirname = b:netrw_curdir - let dirnamelen = s:Strlen(b:netrw_curdir) + let dirnamelen = strlen(b:netrw_curdir) let filelist = glob(s:ComposePath(dirname,"*"),0,1) let filelist = filelist + glob(s:ComposePath(dirname,".*"),0,1) " call Decho("(LocalListing) filelist=".filelist) - if index(filelist,'..') == -1 && b:netrw_curdir != '/' + if g:netrw_cygwin == 0 && (has("win32") || has("win95") || has("win64") || has("win16")) +" call Decho("(LocalListing) filelist=".string(filelist)) + elseif index(filelist,'..') == -1 && b:netrw_curdir !~ '/' " include ../ in the glob() entry if its missing -" call Decho("(LocalListing) forcibly tacking on \"..\"") +" call Decho("(LocalListing) forcibly including on \"..\"") let filelist= filelist+[s:ComposePath(b:netrw_curdir,"../")] " call Decho("(LocalListing) filelist=".string(filelist)) endif @@ -8413,10 +8798,11 @@ fun! s:LocalListing() " call Decho("(LocalListing) dynamic_maxfilenamelen: filenames =".string(filelistcopy)) " call Decho("(LocalListing) dynamic_maxfilenamelen: g:netrw_maxfilenamelen=".g:netrw_maxfilenamelen) endif +" call Decho("(s:LocalListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") for filename in filelist " call Decho("(LocalListing) ") -" call Decho("(LocalListing) (while) filename<".filename.">") +" call Decho("(LocalListing) for filename in filelist: filename<".filename.">") if getftype(filename) == "link" " indicate a symbolic link @@ -8892,6 +9278,26 @@ endfun " --------------------------------------------------------------------- " Support Functions: {{{1 +" --------------------------------------------------------------------- +" netrw#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{2 +fun! netrw#WinPath(path) +" call Dfunc("netrw#WinPath(path<".a:path.">)") + if (!g:netrw_cygwin || &shell !~ '\%(\\|\\)\%(\.exe\)\=$') && (has("win32") || has("win95") || has("win64") || has("win16")) + " remove cygdrive prefix, if present + let path = substitute(a:path,g:netrw_cygdrive.'/\(.\)','\1:','') + " remove trailing slash (Win95) + let path = substitute(path, '\(\\\|/\)$', '', 'g') + " remove escaped spaces + let path = substitute(path, '\ ', ' ', 'g') + " convert slashes to backslashes + let path = substitute(path, '/', '\', 'g') + else + let path= a:path + endif +" call Dret("netrw#WinPath <".path.">") + return path +endfun + " --------------------------------------------------------------------- " netrw#NetrwRestorePosn: restores the cursor and file position as saved by NetrwSavePosn() {{{2 fun! netrw#NetrwRestorePosn(...) @@ -8953,10 +9359,25 @@ fun! netrw#NetrwSavePosn() let ret = "let w:netrw_winnr=".w:netrw_winnr."|let w:netrw_line=".w:netrw_line."|let w:netrw_col=".w:netrw_col."|let w:netrw_hline=".w:netrw_hline keepj call netrw#NetrwRestorePosn() -" call Dret("netrw#NetrwSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline) +" call Dret("netrw#NetrwSavePosn : winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : "n/a")." line=".(exists("w:netrw_line")? w:netrw_line : "n/a")." col=".(exists("w:netrw_col")? w:netrw_col : "n/a")." hline=".(exists("w:netrw_hline")? w:netrw_hline : "n/a")) return ret endfun +" --------------------------------------------------------------------- +" netrw#NetrwAccess: intended to provide access to variable values for netrw's test suite {{{2 +" 0: marked file list of current buffer +" 1: marked file target +fun! netrw#NetrwAccess(ilist) + if a:ilist == 0 + if exists("s:netrwmarkfilelist_".bufnr('%')) + return s:netrwmarkfilelist_{bufnr('%')} + else + return "no-list-buf#".bufnr('%') + endif + elseif a:ilist == 1 + return s:netrwmftgt +endfun + " ------------------------------------------------------------------------ " netrw#RFC2396: converts %xx into characters {{{2 fun! netrw#RFC2396(fname) @@ -9030,7 +9451,7 @@ fun! s:FileReadable(fname) " call Dfunc("s:FileReadable(fname<".a:fname.">)") if g:netrw_cygwin - let ret= filereadable(substitute(a:fname,'/cygdrive/\(.\)','\1:/','')) + let ret= filereadable(substitute(a:fname,g:netrw_cygdrive.'/\(.\)','\1:/','')) else let ret= filereadable(a:fname) endif @@ -9068,7 +9489,7 @@ fun! s:GetTempfile(fname) " o/s dependencies if g:netrw_cygwin != 0 - let tmpfile = substitute(tmpfile,'^\(\a\):','/cygdrive/\1','e') + let tmpfile = substitute(tmpfile,'^\(\a\):',g:netrw_cygdrive.'/\1','e') elseif has("win32") || has("win95") || has("win64") || has("win16") if !exists("+shellslash") || !&ssl let tmpfile = substitute(tmpfile,'/','\','g') @@ -9193,7 +9614,7 @@ fun! s:NetrwCursor() let &l:cursorcolumn = s:netrw_usercuc if w:netrw_liststyle == s:WIDELIST " call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)") - set cursorline + setl cursorline else " call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)") let &l:cursorline = s:netrw_usercul @@ -9257,10 +9678,10 @@ endfun " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2 fun! s:NetrwEnew(...) " call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$")) -" call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">") +" call Decho("(s:NetrwEnew) curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">") " grab a function-local-variable copy of buffer variables -" call Decho("make function-local copy of netrw variables") +" call Decho("(s:NetrwEnew) make function-local copy of netrw variables") if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif if exists("b:netrw_browser_active") |let netrw_browser_active = b:netrw_browser_active |endif if exists("b:netrw_cpf") |let netrw_cpf = b:netrw_cpf |endif @@ -9279,19 +9700,15 @@ fun! s:NetrwEnew(...) if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif keepj call s:NetrwOptionRestore("w:") -" call Decho("generate a buffer with keepjumps keepalt enew!") +" call Decho("(s:NetrwEnew) generate a buffer with keepjumps keepalt enew!") let netrw_keepdiff= &l:diff - " COMBAK: Benzinger: using tree mode, vim -o Foo/ file shows Foo/ Foo/ instead. Place return here, problem goes away (beeps result, but who knows) -" call Dredir("Benzinger 1:","ls!") keepj keepalt enew! -" call Dredir("Benzinger 2:","ls!") - " COMBAK: Benzinger: using tree mode, vim -o Foo/ file shows Foo/ Foo/ instead. Place return here, problem remains. let &l:diff= netrw_keepdiff -" call Decho("bufnr($)=".bufnr("$")) +" call Decho("(s:NetrwEnew) bufnr($)=".bufnr("$")." winnr($)=".winnr("$")) keepj call s:NetrwOptionSave("w:") " copy function-local-variables to buffer variable equivalents -" call Decho("copy function-local variables back to buffer netrw variables") +" call Decho("(s:NetrwEnew) copy function-local variables back to buffer netrw variables") if exists("netrw_bannercnt") |let b:netrw_bannercnt = netrw_bannercnt |endif if exists("netrw_browser_active") |let b:netrw_browser_active = netrw_browser_active |endif if exists("netrw_cpf") |let b:netrw_cpf = netrw_cpf |endif @@ -9323,7 +9740,7 @@ fun! s:NetrwEnew(...) endif endif -" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh) +" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh." win#".winnr()." winnr($)#".winnr("$")) endfun " --------------------------------------------------------------------- @@ -9392,12 +9809,12 @@ endfun fun! s:RemotePathAnalysis(dirname) " call Dfunc("s:RemotePathAnalysis(a:dirname<".a:dirname.">)") - let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$' + let dirpat = '^\(\w\{-}\)://\(\(\w\+\)@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$' let s:method = substitute(a:dirname,dirpat,'\1','') - let s:user = substitute(a:dirname,dirpat,'\2','') - let s:machine = substitute(a:dirname,dirpat,'\3','') - let s:port = substitute(a:dirname,dirpat,'\4','') - let s:path = substitute(a:dirname,dirpat,'\5','') + let s:user = substitute(a:dirname,dirpat,'\3','') + let s:machine = substitute(a:dirname,dirpat,'\4','') + let s:port = substitute(a:dirname,dirpat,'\5','') + let s:path = substitute(a:dirname,dirpat,'\6','') let s:fname = substitute(a:dirname,'^.*/\ze.','','') " call Decho("set up s:method <".s:method .">") @@ -9476,9 +9893,10 @@ fun! s:NetrwRexplore(islocal,dirname) endif " call Dfunc("s:NetrwRexplore() w:netrw_rexlocal=".w:netrw_rexlocal." w:netrw_rexdir<".w:netrw_rexdir.">") if !exists("w:netrw_rexlocal") -" " call Dret("s:NetrwRexplore() w:netrw_rexlocal doesn't exist") +" call Dret("s:NetrwRexplore() w:netrw_rexlocal doesn't exist") return endif +" call Decho("(NetrwRexplore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) if w:netrw_rexlocal keepj call netrw#LocalBrowseCheck(w:netrw_rexdir) else @@ -9497,11 +9915,13 @@ fun! s:NetrwRexplore(islocal,dirname) if exists("s:explore_match") exe "2match netrwMarkFile /".s:explore_match."/" endif +" call Decho("(NetrwRexplore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) " call Dret("s:NetrwRexplore") endfun " --------------------------------------------------------------------- -" s:SaveBufVars: {{{2 +" s:SaveBufVars: save selected b: variables to s: variables {{{2 +" use s:RestoreBufVars() to restore b: variables from s: variables fun! s:SaveBufVars() " call Dfunc("s:SaveBufVars() buf#".bufnr("%")) @@ -9572,42 +9992,48 @@ fun! s:SetRexDir(islocal,dirname) endfun " --------------------------------------------------------------------- -" s:Strlen: this function returns the length of a string, even if its {{{2 -" using multiple-byte characters. -" Solution from Nicolai Weibull, vim docs (:help strlen()), Tony Mechelynck, -" and a bit from me. -" if g:netrw_xstrlen is zero (default), then the builtin strlen() function is used. +" s:Strlen: this function returns the length of a string, even if its using multi-byte characters. {{{2 +" Solution from Nicolai Weibull, vim docs (:help strlen()), +" Tony Mechelynck, and my own invention. fun! s:Strlen(x) -" call Dfunc("s:Strlen(x<".a:x.">") - if g:netrw_xstrlen == 1 +" "" call Dfunc("s:Strlen(x<".a:x."> g:Align_xstrlen=".g:Align_xstrlen.")") + + if v:version >= 703 && exists("*strdisplaywidth") + let ret= strdisplaywidth(a:x) + + elseif type(g:Align_xstrlen) == 1 + " allow user to specify a function to compute the string length (ie. let g:Align_xstrlen="mystrlenfunc") + exe "let ret= ".g:Align_xstrlen."('".substitute(a:x,"'","''","g")."')" + + elseif g:Align_xstrlen == 1 " number of codepoints (Latin a + combining circumflex is two codepoints) " (comment from TM, solution from NW) let ret= strlen(substitute(a:x,'.','c','g')) - - elseif g:netrw_xstrlen == 2 - " number of spacing codepoints (Latin a + combining circumflex is one spacing + + elseif g:Align_xstrlen == 2 + " number of spacing codepoints (Latin a + combining circumflex is one spacing " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.) " (comment from TM, solution from TM) - let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) - - elseif g:netrw_xstrlen == 3 - " virtual length (counting, for instance, tabs as anything between 1 and - " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately + let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) + + elseif g:Align_xstrlen == 3 + " virtual length (counting, for instance, tabs as anything between 1 and + " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately " preceded by lam, one otherwise, etc.) " (comment from TM, solution from me) - let modkeep= &mod - exe "keepj norm! o\" + let modkeep= &l:mod + exe "norm! o\" call setline(line("."),a:x) let ret= virtcol("$") - 1 - keepj d + d keepj norm! k - let &mod= modkeep - + let &l:mod= modkeep + else " at least give a decent default - let ret= strlen(a:x) + let ret= strlen(a:x) endif -" call Dret("s:Strlen ".ret) +" "" call Dret("s:Strlen ".ret) return ret endfun @@ -9619,7 +10045,7 @@ fun! s:TreeListMove(dir) let prvline = (line(".") > 1)? getline(line(".")-1) : '' let nxtline = (line(".") < line("$"))? getline(line(".")+1) : '' let curindent= substitute(curline,'^\([| ]*\).\{-}$','\1','') - let indentm1 = substitute(curindent,'^| ','','') + let indentm1 = substitute(curindent,'^'.s:treedepthstring.' ','','') " call Decho("prvline <".prvline."> #".line(".")-1) " call Decho("curline <".curline."> #".line(".")) " call Decho("nxtline <".nxtline."> #".line(".")+1) @@ -9630,22 +10056,22 @@ fun! s:TreeListMove(dir) " call Decho('regfile') if a:dir == '[' && prvline != '' keepj norm! 0 - let nl = search('^'.indentm1.'[^|]','bWe') " search backwards from regular file + let nl = search('^'.indentm1.'[^'.s:treedepthstring.']','bWe') " search backwards from regular file " call Decho("regfile srch back: ".nl) elseif a:dir == ']' && nxtline != '' keepj norm! $ - let nl = search('^'.indentm1.'[^|]','We') " search forwards from regular file + let nl = search('^'.indentm1.'[^'.s:treedepthstring.']','We') " search forwards from regular file " call Decho("regfile srch fwd: ".nl) endif elseif a:dir == '[' && prvline != '' keepj norm! 0 let curline= line(".") - let nl = search('^'.curindent.'[^|]','bWe') " search backwards From directory, same indentation + let nl = search('^'.curindent.'[^'.s:treedepthstring.']','bWe') " search backwards From directory, same indentation " call Decho("dir srch back ind: ".nl) if nl != 0 if line(".") == curline-1 - let nl= search('^'.indentm1.'[^|]','bWe') " search backwards from directory, indentation - 1 + let nl= search('^'.indentm1.'[^'.s:treedepthstring.']','bWe') " search backwards from directory, indentation - 1 " call Decho("dir srch back ind-1: ".nl) endif endif @@ -9653,11 +10079,11 @@ fun! s:TreeListMove(dir) elseif a:dir == ']' && nxtline != '' keepj norm! $ let curline = line(".") - let nl = search('^'.curindent.'[^|]','We') " search forwards from directory, same indentation + let nl = search('^'.curindent.'[^'.s:treedepthstring.']','We') " search forwards from directory, same indentation " call Decho("dir srch fwd ind: ".nl) if nl != 0 if line(".") == curline+1 - let nl= search('^'.indentm1.'[^|]','We') " search forwards from directory, indentation - 1 + let nl= search('^'.indentm1.'[^'.s:treedepthstring.']','We') " search forwards from directory, indentation - 1 " call Decho("dir srch fwd ind-1: ".nl) endif endif @@ -9704,27 +10130,7 @@ fun! s:UseBufWinVars() endfun " --------------------------------------------------------------------- -" netrw#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{2 -fun! netrw#WinPath(path) -" call Dfunc("netrw#WinPath(path<".a:path.">)") - if (!g:netrw_cygwin || &shell !~ '\%(\\|\\)\%(\.exe\)\=$') && (has("win32") || has("win95") || has("win64") || has("win16")) - " remove cygdrive prefix, if present - let path = substitute(a:path,'/cygdrive/\(.\)','\1:','') - " remove trailing slash (Win95) - let path = substitute(path, '\(\\\|/\)$', '', 'g') - " remove escaped spaces - let path = substitute(path, '\ ', ' ', 'g') - " convert slashes to backslashes - let path = substitute(path, '/', '\', 'g') - else - let path= a:path - endif -" call Dret("netrw#WinPath <".path.">") - return path -endfun - -" --------------------------------------------------------------------- -" Settings Restoration: {{{2 +" Settings Restoration: {{{1 let &cpo= s:keepcpo unlet s:keepcpo diff --git a/vimfiles/autoload/netrwFileHandlers.vim b/vimfiles/autoload/netrwFileHandlers.vim index 84f70c4..ed31e29 100644 --- a/vimfiles/autoload/netrwFileHandlers.vim +++ b/vimfiles/autoload/netrwFileHandlers.vim @@ -1,8 +1,8 @@ " netrwFileHandlers: contains various extension-based file handlers for " netrw's browsers' x command ("eXecute launcher") " Author: Charles E. Campbell -" Date: Mar 14, 2012 -" Version: 11a +" Date: May 03, 2013 +" Version: 11b ASTRO-ONLY " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright @@ -20,7 +20,7 @@ if exists("g:loaded_netrwFileHandlers") || &cp finish endif -let g:loaded_netrwFileHandlers= "v11a" +let g:loaded_netrwFileHandlers= "v11b" if v:version < 702 echohl WarningMsg echo "***warning*** this version of netrwFileHandlers needs vim 7.2" @@ -34,10 +34,10 @@ set cpo&vim " netrwFileHandlers#Invoke: {{{1 fun! netrwFileHandlers#Invoke(exten,fname) " call Dfunc("netrwFileHandlers#Invoke(exten<".a:exten."> fname<".a:fname.">)") - let fname= a:fname + let exten= a:exten " list of supported special characters. Consider rcs,v --- that can be " supported with a NFH_rcsCOMMAv() handler - if a:fname =~ '[@:,$!=\-+%?;~]' + if exten =~ '[@:,$!=\-+%?;~]' let specials= { \ '@' : 'AT', \ ':' : 'COLON', @@ -51,18 +51,18 @@ fun! netrwFileHandlers#Invoke(exten,fname) \ '?' : 'QUESTION', \ ';' : 'SEMICOLON', \ '~' : 'TILDE'} - let fname= substitute(a:fname,'[@:,$!=\-+%?;~]','\=specials[submatch(0)]','ge') + let exten= substitute(a:exten,'[@:,$!=\-+%?;~]','\=specials[submatch(0)]','ge') " call Decho('fname<'.fname.'> done with dictionary') endif - if a:exten != "" && exists("*NFH_".a:exten) + if a:exten != "" && exists("*NFH_".exten) " support user NFH_*() functions " call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")') - exe "let ret= NFH_".a:exten.'("'.fname.'")' - elseif a:exten != "" && exists("*s:NFH_".a:exten) + exe "let ret= NFH_".exten.'("'.a:fname.'")' + elseif a:exten != "" && exists("*s:NFH_".exten) " use builtin-NFH_*() functions " call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")') - exe "let ret= s:NFH_".a:exten.'("'.fname.'")' + exe "let ret= s:NFH_".a:exten.'("'.a:fname.'")' endif " call Dret("netrwFileHandlers#Invoke 0 : ret=".ret) diff --git a/vimfiles/autoload/netrwSettings.vim b/vimfiles/autoload/netrwSettings.vim index 68348d8..541ee65 100644 --- a/vimfiles/autoload/netrwSettings.vim +++ b/vimfiles/autoload/netrwSettings.vim @@ -1,7 +1,7 @@ " netrwSettings.vim: makes netrw settings simpler -" Date: Sep 03, 2008 +" Date: Aug 27, 2013 " Maintainer: Charles E Campbell -" Version: 13 +" Version: 14 " Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright @@ -19,7 +19,7 @@ if exists("g:loaded_netrwSettings") || &cp finish endif -let g:loaded_netrwSettings = "v13" +let g:loaded_netrwSettings = "v14" if v:version < 700 echohl WarningMsg echo "***warning*** this version of netrwSettings needs vim 7.0" @@ -88,6 +88,7 @@ fun! netrwSettings#NetrwSettings() put = 'let g:netrw_ftpmode = '.g:netrw_ftpmode put = 'let g:netrw_ignorenetrc = '.g:netrw_ignorenetrc put = 'let g:netrw_sshport = '.g:netrw_sshport + put = 'let g:netrw_silent = '.g:netrw_silent put = 'let g:netrw_use_nt_rcp = '.g:netrw_use_nt_rcp put = 'let g:netrw_win95ftp = '.g:netrw_win95ftp let s:netrw_xfer_stop= line(".") @@ -97,29 +98,57 @@ fun! netrwSettings#NetrwSettings() put = '' put ='+ Netrw Browser Control' + if exists("g:netrw_altfile") + put = 'let g:netrw_altfile = '.g:netrw_altfile + else + put = 'let g:netrw_altfile = 0' + endif put = 'let g:netrw_alto = '.g:netrw_alto put = 'let g:netrw_altv = '.g:netrw_altv + put = 'let g:netrw_banner = '.g:netrw_banner + if exists("g:netrw_bannerbackslash") + put = 'let g:netrw_bannerbackslash = '.g:netrw_bannerbackslash + else + put = '\" let g:netrw_bannerbackslash = (not defined)' + endif put = 'let g:netrw_browse_split = '.g:netrw_browse_split if exists("g:netrw_browsex_viewer") - put = 'let g:netrw_browsex_viewer = '.g:netrw_browsex_viewer + put = 'let g:netrw_browsex_viewer = '.g:netrw_browsex_viewer else - put = 'let g:netrw_browsex_viewer = (not defined)' + put = '\" let g:netrw_browsex_viewer = (not defined)' endif put = 'let g:netrw_compress = '.g:netrw_compress + if exists("g:Netrw_corehandler") + put = 'let g:Netrw_corehandler = '.g:Netrw_corehandler + else + put = '\" let g:Netrw_corehandler = (not defined)' + endif + put = 'let g:netrw_ctags = '.g:netrw_ctags put = 'let g:netrw_cursor = '.g:netrw_cursor let decompressline= line("$") - put ='let g:netrw_decompress...' + put = 'let g:netrw_decompress = '.string(g:netrw_decompress) + if exists("g:netrw_dynamic_maxfilenamelen") + put = 'let g:netrw_dynamic_maxfilenamelen='.g:netrw_dynamic_maxfilenamelen + else + put = '\" let g:netrw_dynamic_maxfilenamelen= (not defined)' + endif put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax + put = 'let g:netrw_errorlvl = '.g:netrw_errorlvl put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse let fnameescline= line("$") - put = 'let g:netrw_fname_escape...' + put = 'let g:netrw_fname_escape = '.string(g:netrw_fname_escape) put = 'let g:netrw_ftp_browse_reject = '.g:netrw_ftp_browse_reject put = 'let g:netrw_ftp_list_cmd = '.g:netrw_ftp_list_cmd put = 'let g:netrw_ftp_sizelist_cmd = '.g:netrw_ftp_sizelist_cmd put = 'let g:netrw_ftp_timelist_cmd = '.g:netrw_ftp_timelist_cmd let globescline= line("$") - put ='let g:netrw_glob_escape...' + put = 'let g:netrw_glob_escape = '.string(g:netrw_glob_escape) put = 'let g:netrw_hide = '.g:netrw_hide + if exists("g:netrw_home") + put = 'let g:netrw_home = '.g:netrw_home + else + put = '\" let g:netrw_home = (not defined)' + endif put = 'let g:netrw_keepdir = '.g:netrw_keepdir put = 'let g:netrw_list_cmd = '.g:netrw_list_cmd put = 'let g:netrw_list_hide = '.g:netrw_list_hide @@ -127,23 +156,30 @@ fun! netrwSettings#NetrwSettings() put = 'let g:netrw_localcopycmd = '.g:netrw_localcopycmd put = 'let g:netrw_localmkdir = '.g:netrw_localmkdir put = 'let g:netrw_localmovecmd = '.g:netrw_localmovecmd - put = 'let g:netrw_localrmdir = '.g:netrw_localrmdir + put = 'let g:netrw_localrmdir = '.g:netrw_localrmdir put = 'let g:netrw_maxfilenamelen = '.g:netrw_maxfilenamelen put = 'let g:netrw_menu = '.g:netrw_menu + put = 'let g:netrw_mousemaps = '.g:netrw_mousemaps put = 'let g:netrw_mkdir_cmd = '.g:netrw_mkdir_cmd + if exists("g:netrw_nobeval") + put = 'let g:netrw_nobeval = '.g:netrw_nobeval + else + put = '\" let g:netrw_nobeval = (not defined)' + endif + put = 'let g:netrw_remote_mkdir = '.g:netrw_remote_mkdir put = 'let g:netrw_preview = '.g:netrw_preview put = 'let g:netrw_rename_cmd = '.g:netrw_rename_cmd put = 'let g:netrw_retmap = '.g:netrw_retmap put = 'let g:netrw_rm_cmd = '.g:netrw_rm_cmd put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd put = 'let g:netrw_rmf_cmd = '.g:netrw_rmf_cmd - put = 'let g:netrw_silent = '.g:netrw_silent put = 'let g:netrw_sort_by = '.g:netrw_sort_by put = 'let g:netrw_sort_direction = '.g:netrw_sort_direction put = 'let g:netrw_sort_options = '.g:netrw_sort_options put = 'let g:netrw_sort_sequence = '.g:netrw_sort_sequence put = 'let g:netrw_special_syntax = '.g:netrw_special_syntax put = 'let g:netrw_ssh_browse_reject = '.g:netrw_ssh_browse_reject + put = 'let g:netrw_ssh_cmd = '.g:netrw_ssh_cmd put = 'let g:netrw_scpport = '.g:netrw_scpport put = 'let g:netrw_sepchr = '.g:netrw_sepchr put = 'let g:netrw_sshport = '.g:netrw_sshport diff --git a/vimfiles/autoload/netrw_gitignore.vim b/vimfiles/autoload/netrw_gitignore.vim new file mode 100644 index 0000000..0de902c --- /dev/null +++ b/vimfiles/autoload/netrw_gitignore.vim @@ -0,0 +1,71 @@ +" netrw_gitignore#Hide: gitignore-based hiding +" Function returns a string of comma separated patterns convenient for +" assignment to `g:netrw_list_hide` option. +" Function can take additional filenames as arguments, example: +" netrw_gitignore#Hide('custom_gitignore1', 'custom_gitignore2') +" +" Usage examples: +" let g:netrw_list_hide = netrw_gitignore#Hide() +" let g:netrw_list_hide = netrw_gitignore#Hide() . 'more,hide,patterns' +" +" Copyright: Copyright (C) 2013 Bruno Sutic {{{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, +" netrw_gitignore.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. +function! netrw_gitignore#Hide(...) + let additional_files = a:000 + + let default_files = ['.gitignore', '.git/info/exclude'] + + " get existing global/system gitignore files + let global_gitignore = expand(substitute(system("git config --global core.excludesfile"), '\n', '', 'g')) + if global_gitignore !=# '' + let default_files = add(default_files, global_gitignore) + endif + let system_gitignore = expand(substitute(system("git config --system core.excludesfile"), '\n', '', 'g')) + if system_gitignore !=# '' + let default_files = add(default_files, system_gitignore) + endif + + " append additional files if given as function arguments + if additional_files !=# [] + let files = extend(default_files, additional_files) + else + let files = default_files + endif + + " keep only existing/readable files + let gitignore_files = [] + for file in files + if filereadable(file) + let gitignore_files = add(gitignore_files, file) + endif + endfor + + " get contents of gitignore patterns from those files + let gitignore_lines = [] + for file in gitignore_files + for line in readfile(file) + " filter empty lines and comments + if line !~# '^#' && line !~# '^$' + let gitignore_lines = add(gitignore_lines, line) + endif + endfor + endfor + + " convert gitignore patterns to Netrw/Vim regex patterns + let escaped_lines = [] + for line in gitignore_lines + let escaped = line + let escaped = substitute(escaped, '\.', '\\.', 'g') + let escaped = substitute(escaped, '*', '.*', 'g') + let escaped_lines = add(escaped_lines, escaped) + endfor + + return join(escaped_lines, ',') +endfunction diff --git a/vimfiles/autoload/tcomment.vim b/vimfiles/autoload/tcomment.vim index 5c3d066..eeecb11 100644 --- a/vimfiles/autoload/tcomment.vim +++ b/vimfiles/autoload/tcomment.vim @@ -1,16 +1,23 @@ -" tcomment.vim " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-09-17. -" @Last Change: 2012-12-10. -" @Revision: 0.0.614 +" @Last Change: 2014-02-05. +" @Revision: 1587 " call tlog#Log('Load: '. expand('')) " vimtlib-sfile -if !exists("g:tcommentBlankLines") - " If true, comment blank lines too - let g:tcommentBlankLines = 1 "{{{2 +if !exists("g:tcomment#blank_lines") + " If 1, comment blank lines too. + " If 2, also comment blank lines within indented code blocks + " (requires mixedindent -- see |tcomment#Comment()|). + let g:tcomment#blank_lines = 2 "{{{2 +endif + +if !exists('g:tcomment#rstrip_on_uncomment') + " If 1, remove right-hand whitespace on uncomment from empty lines. + " If 2, remove right-hand whitespace on uncomment from all lines. + let g:tcomment#rstrip_on_uncomment = 1 "{{{2 endif if !exists("g:tcommentModeExtra") @@ -40,6 +47,16 @@ if !exists('g:tcommentOptions') let g:tcommentOptions = {} "{{{2 endif +if !exists('g:tcomment#options_comments') + " Options when using a the 'comments' option. + let g:tcomment#options_comments = {'whitespace': 'both'} "{{{2 +endif + +if !exists('g:tcomment#options_commentstring') + " Options when using a the 'commentstring' option. + let g:tcomment#options_commentstring = {'whitespace': 'both'} "{{{2 +endif + if !exists('g:tcomment#ignore_char_type') " |text-objects| for use with |tcomment#Operator| can have different " types: line, block, char etc. Text objects like aB, it, at etc. @@ -73,6 +90,10 @@ if !exists("g:tcommentGuessFileType_php") " html. let g:tcommentGuessFileType_php = 'html' "{{{2 endif +if !exists("g:tcommentGuessFileType_blade") + " See |g:tcommentGuessFileType_php|. + let g:tcommentGuessFileType_blade = 'html' "{{{2 +endif if !exists("g:tcommentGuessFileType_html") let g:tcommentGuessFileType_html = 1 "{{{2 endif @@ -103,7 +124,18 @@ if !exists('g:tcomment#syntax_substitute') " :read: let g:tcomment#syntax_substitute = {...} "{{{2 " Perform replacements on the syntax name. let g:tcomment#syntax_substitute = { - \ '\C^javaScript': {'sub': 'javascript'} + \ '\C^javaScript\ze\(\u\|$\)': {'sub': 'javascript'}, + \ '\C^js\ze\(\u\|$\)': {'sub': 'javascript'} + \ } +endif + +if !exists('g:tcomment#filetype_map') + " Keys must match the full |filetype|. Regexps must be |magic|. No + " regexp modifiers (like |\V|) are allowed. + " let g:tcomment#filetype_map = {...} "{{{2 + let g:tcomment#filetype_map = { + \ 'rails-views': 'html', + \ 'mkd': 'html', \ } endif @@ -114,6 +146,7 @@ if !exists('g:tcommentSyntaxMap') " mapped onto the corresponding filetype. " :read: let g:tcommentSyntaxMap = {...} "{{{2 let g:tcommentSyntaxMap = { + \ 'erubyExpression': 'ruby', \ 'vimMzSchemeRegion': 'scheme', \ 'vimPerlRegion': 'perl', \ 'vimPythonRegion': 'python', @@ -146,21 +179,28 @@ if !exists('g:tcomment#replacements_c') \ } endif -if !exists("g:tcommentLineC") - " Generic c-like block comments. - " :read: let g:tcommentBlockC = {...} "{{{2 - let g:tcommentLineC = { +if !exists("g:tcommentInlineC") + " Generic c-like comments. + " :read: let g:tcommentInlineC = {...} "{{{2 + let g:tcommentInlineC = { \ 'commentstring': '/* %s */', + \ 'rxbeg': '\*\+', + \ 'rxend': '', + \ 'rxmid': '', \ 'replacements': g:tcomment#replacements_c \ } endif +if !exists("g:tcommentLineC") + " Generic c-like block comments. + let g:tcommentLineC = g:tcommentInlineC +endif if !exists("g:tcommentBlockC") let g:tcommentBlockC = { \ 'commentstring': '/*%s */', \ 'middle': ' * ', \ 'rxbeg': '\*\+', - \ 'rxend': '\*\+', - \ 'rxmid': '\*\+', + \ 'rxend': '', + \ 'rxmid': '', \ 'replacements': g:tcomment#replacements_c \ } endif @@ -176,21 +216,43 @@ if !exists("g:tcommentBlockC2") \ 'replacements': g:tcomment#replacements_c \ } endif -if !exists("g:tcommentInlineC") - " Generic c-like comments. - let g:tcommentInlineC = g:tcommentLineC "{{{2 + +if !exists('g:tcomment#replacements_xml') + " Replacements for xml filetype. + " :read: let g:tcomment#replacements_xml = {...} "{{{2 + let g:tcomment#replacements_xml = { + \ '-': '-', + \ '&': '&', + \ } endif if !exists("g:tcommentBlockXML") " Generic xml-like block comments. - let g:tcommentBlockXML = "\n " "{{{2 + " :read: let g:tcommentBlockXML = {...} "{{{2 + let g:tcommentBlockXML = { + \ 'commentstring': "\n ", + \ 'replacements': g:tcomment#replacements_xml + \ } endif if !exists("g:tcommentInlineXML") " Generic xml-like comments. - let g:tcommentInlineXML = "" "{{{2 + " :read: let g:tcommentInlineXML = {...} "{{{2 + let g:tcommentInlineXML = { + \ 'commentstring': "", + \ 'replacements': g:tcomment#replacements_xml + \ } endif -let s:typesDirty = 1 +if !exists('g:tcomment#ignore_comment_def') + " A list of names or filetypes, which should be ignored by + " |tcomment#DefineType()| -- no custom comment definition will be + " stored for these names. + " + " This variable should be set before loading autoload/tcomment.vim. + let g:tcomment#ignore_comment_def = [] "{{{2 +endif + +let s:types_dirty = 1 let s:definitions = {} @@ -221,8 +283,12 @@ let s:definitions = {} " See the help on the args argument of |tcomment#Comment| (see item 1, " args is a list of key=value pairs) to find out which fields can be " used. -function! tcomment#DefineType(name, commentdef) - if !has_key(s:definitions, a:name) +" :display: tcomment#DefineType(name, commentdef, ?cdef={}, ?anyway=0) +function! tcomment#DefineType(name, commentdef, ...) + let basename = matchstr(a:name, '^[^_]\+') + let use = a:0 >= 2 ? a:2 : len(filter(copy(g:tcomment#ignore_comment_def), 'v:val == basename')) == 0 + " TLogVAR a:name, use + if use if type(a:commentdef) == 4 let cdef = copy(a:commentdef) else @@ -231,21 +297,230 @@ function! tcomment#DefineType(name, commentdef) endif let s:definitions[a:name] = cdef endif - let s:typesDirty = 1 + let s:types_dirty = 1 endf -" :nodoc: -" Return comment definition -function! tcomment#GetCommentDef(name) - return get(s:definitions, a:name, "") +" Return the comment definition for NAME. +" *b:tcomment_def_{NAME}* +" Return b:tcomment_def_{NAME} if the variable exists. Otherwise return +" the comment definition as set with |tcomment#DefineType|. +function! tcomment#GetCommentDef(name, ...) + if exists('b:tcomment_def_'. a:name) + return b:tcomment_def_{a:name} + else + return get(s:definitions, a:name, a:0 >= 1 ? a:1 : '') + endif endf " :nodoc: " Return 1 if a comment type is defined. -function! tcomment#TypeExists(name) - return has_key(s:definitions, a:name) +function! tcomment#TypeExists(name, ...) + let comment_mode = a:0 >= 1 ? a:1 : '' + let name = a:name + if comment_mode =~? 'b' + let name .= '_block' + elseif comment_mode =~? 'i' + let name .= '_inline' + endif + return has_key(s:definitions, name) ? name : '' endf +call tcomment#DefineType('aap', '# %s' ) +call tcomment#DefineType('ada', '-- %s' ) +call tcomment#DefineType('apache', '# %s' ) +call tcomment#DefineType('asciidoc', '// %s' ) +call tcomment#DefineType('asm', '; %s' ) +call tcomment#DefineType('blade', '{{-- %s --}}' ) +call tcomment#DefineType('blade_block', '{{-- %s --}}' ) +call tcomment#DefineType('blade_inline', '{{-- %s --}}' ) +call tcomment#DefineType('c', g:tcommentLineC ) +call tcomment#DefineType('c_block', g:tcommentBlockC ) +call tcomment#DefineType('c_inline', g:tcommentInlineC ) +call tcomment#DefineType('catalog', '-- %s --' ) +call tcomment#DefineType('catalog_block', "--%s--\n " ) +call tcomment#DefineType('cfg', '# %s' ) +call tcomment#DefineType('chromemanifest', '# %s' ) +call tcomment#DefineType('clojure', {'commentstring': '; %s', 'count': 2}) +call tcomment#DefineType('clojure_inline', '; %s' ) +call tcomment#DefineType('clojurescript', ';; %s' ) +call tcomment#DefineType('clojurescript_inline', '; %s' ) +call tcomment#DefineType('cmake', '# %s' ) +call tcomment#DefineType('coffee', '# %s' ) +call tcomment#DefineType('conf', '# %s' ) +call tcomment#DefineType('conkyrc', '# %s' ) +call tcomment#DefineType('cpp', '// %s' ) +call tcomment#DefineType('cpp_block', g:tcommentBlockC ) +call tcomment#DefineType('cpp_inline', g:tcommentInlineC ) +call tcomment#DefineType('crontab', '# %s' ) +call tcomment#DefineType('cs', '// %s' ) +call tcomment#DefineType('cs_block', g:tcommentBlockC ) +call tcomment#DefineType('cs_inline', g:tcommentInlineC ) +call tcomment#DefineType('css', '/* %s */' ) +call tcomment#DefineType('css_block', g:tcommentBlockC ) +call tcomment#DefineType('css_inline', g:tcommentInlineC ) +call tcomment#DefineType('debcontrol', '# %s' ) +call tcomment#DefineType('debsources', '# %s' ) +call tcomment#DefineType('desktop', '# %s' ) +call tcomment#DefineType('dnsmasq', '# %s' ) +call tcomment#DefineType('docbk', g:tcommentInlineXML) +call tcomment#DefineType('docbk_block', g:tcommentBlockXML ) +call tcomment#DefineType('docbk_inline', g:tcommentInlineXML) +call tcomment#DefineType('dosbatch', 'rem %s' ) +call tcomment#DefineType('dosini', '; %s' ) +call tcomment#DefineType('dsl', '; %s' ) +call tcomment#DefineType('dustjs', '{! %s !}' ) +call tcomment#DefineType('dylan', '// %s' ) +call tcomment#DefineType('eiffel', '-- %s' ) +call tcomment#DefineType('erlang', '%%%% %s' ) +call tcomment#DefineType('eruby', '<%%# %s' ) +call tcomment#DefineType('esmtprc', '# %s' ) +call tcomment#DefineType('expect', '# %s' ) +call tcomment#DefineType('form', {'commentstring': '* %s', 'col': 1}) +call tcomment#DefineType('fstab', '# %s' ) +call tcomment#DefineType('gitcommit', '# %s' ) +call tcomment#DefineType('gitignore', '# %s' ) +call tcomment#DefineType('gnuplot', '# %s' ) +call tcomment#DefineType('go', '// %s' ) +call tcomment#DefineType('go_block', g:tcommentBlockC ) +call tcomment#DefineType('go_inline', g:tcommentInlineC ) +call tcomment#DefineType('groovy', '// %s' ) +call tcomment#DefineType('groovy_block', g:tcommentBlockC ) +call tcomment#DefineType('groovy_doc_block', g:tcommentBlockC2 ) +call tcomment#DefineType('groovy_inline', g:tcommentInlineC ) +call tcomment#DefineType('gtkrc', '# %s' ) +call tcomment#DefineType('haml', '-# %s' ) +call tcomment#DefineType('haskell', '-- %s' ) +call tcomment#DefineType('haskell_block', "{-%s-}\n " ) +call tcomment#DefineType('haskell_inline', '{- %s -}' ) +call tcomment#DefineType('html', g:tcommentInlineXML) +call tcomment#DefineType('html_block', g:tcommentBlockXML ) +call tcomment#DefineType('html_inline', g:tcommentInlineXML) +call tcomment#DefineType('htmldjango', '{# %s #}' ) +call tcomment#DefineType('htmldjango_block', "{%% comment %%}%s{%% endcomment %%}\n ") +call tcomment#DefineType('htmljinja', '{# %s #}' ) +call tcomment#DefineType('htmljinja_block', "{%% comment %%}%s{%% endcomment %%}\n ") +call tcomment#DefineType('hy', '; %s' ) +call tcomment#DefineType('ini', '; %s' ) " php ini (/etc/php5/...) +call tcomment#DefineType('io', '// %s' ) +call tcomment#DefineType('jasmine', '# %s' ) +call tcomment#DefineType('java', '/* %s */' ) +call tcomment#DefineType('java_block', g:tcommentBlockC ) +call tcomment#DefineType('java_doc_block', g:tcommentBlockC2 ) +call tcomment#DefineType('java_inline', g:tcommentInlineC ) +" call tcomment#DefineType('javaScript', '// %s' ) +" call tcomment#DefineType('javaScript_block', g:tcommentBlockC ) +" call tcomment#DefineType('javaScript_inline', g:tcommentInlineC ) +call tcomment#DefineType('javascript', '// %s' ) +call tcomment#DefineType('javascript_block', g:tcommentBlockC ) +call tcomment#DefineType('javascript_inline', g:tcommentInlineC ) +call tcomment#DefineType('jproperties', '# %s' ) +call tcomment#DefineType('lisp', '; %s' ) +call tcomment#DefineType('lua', '-- %s' ) +call tcomment#DefineType('lua_block', "--[[%s--]]\n" ) +call tcomment#DefineType('lua_inline', '--[[%s --]]' ) +call tcomment#DefineType('lynx', '# %s' ) +call tcomment#DefineType('m4', 'dnl %s' ) +call tcomment#DefineType('mail', '> %s' ) +call tcomment#DefineType('matlab', '%% %s' ) +call tcomment#DefineType('monkey', ''' %s' ) +call tcomment#DefineType('msidl', '// %s' ) +call tcomment#DefineType('msidl_block', g:tcommentBlockC ) +call tcomment#DefineType('nginx', '# %s' ) +call tcomment#DefineType('nroff', '.\\" %s' ) +call tcomment#DefineType('nsis', '# %s' ) +call tcomment#DefineType('objc', '/* %s */' ) +call tcomment#DefineType('objc_block', g:tcommentBlockC ) +call tcomment#DefineType('objc_inline', g:tcommentInlineC ) +call tcomment#DefineType('objcpp', '// %s' ) +call tcomment#DefineType('ocaml', '(* %s *)' ) +call tcomment#DefineType('ocaml_block', "(*%s*)\n " ) +call tcomment#DefineType('ocaml_inline', '(* %s *)' ) +call tcomment#DefineType('pac', '// %s' ) +call tcomment#DefineType('pascal', '(* %s *)' ) +call tcomment#DefineType('pascal_block', "(*%s*)\n " ) +call tcomment#DefineType('pascal_inline', '(* %s *)' ) +call tcomment#DefineType('perl', '# %s' ) +call tcomment#DefineType('perl_block', "=cut%s=cut" ) +call tcomment#DefineType('pfmain', '# %s' ) +call tcomment#DefineType('php', {'commentstring_rx': '\%%(//\|#\) %s', 'commentstring': '// %s'}) +call tcomment#DefineType('php_2_block', g:tcommentBlockC2 ) +call tcomment#DefineType('php_block', g:tcommentBlockC ) +call tcomment#DefineType('php_inline', g:tcommentInlineC ) +call tcomment#DefineType('po', '# %s' ) +call tcomment#DefineType('prolog', '%% %s' ) +call tcomment#DefineType('puppet', '# %s' ) +call tcomment#DefineType('python', '# %s' ) +call tcomment#DefineType('qml', '// %s' ) +call tcomment#DefineType('r', '# %s' ) +call tcomment#DefineType('racket', '; %s' ) +call tcomment#DefineType('racket_block', '#|%s|#' ) +call tcomment#DefineType('rc', '// %s' ) +call tcomment#DefineType('readline', '# %s' ) +call tcomment#DefineType('remind', {'commentstring_rx': '\[;#] %s', 'commentstring': '# %s'}) +call tcomment#DefineType('resolv', '# %s' ) +call tcomment#DefineType('robots', '# %s' ) +call tcomment#DefineType('ruby', '# %s' ) +call tcomment#DefineType('ruby_3', '### %s' ) +call tcomment#DefineType('ruby_block', "=begin rdoc%s=end") +call tcomment#DefineType('ruby_nodoc_block', "=begin%s=end" ) +call tcomment#DefineType('samba', '# %s' ) +call tcomment#DefineType('sbs', "' %s" ) +call tcomment#DefineType('scala', '// %s' ) +call tcomment#DefineType('scala_block', g:tcommentBlockC ) +call tcomment#DefineType('scala_inline', g:tcommentInlineC ) +call tcomment#DefineType('scheme', '; %s' ) +call tcomment#DefineType('scheme_block', '#|%s|#' ) +call tcomment#DefineType('scss', '// %s' ) +call tcomment#DefineType('scss_block', g:tcommentBlockC ) +call tcomment#DefineType('scss_inline', g:tcommentInlineC ) +call tcomment#DefineType('sed', '# %s' ) +call tcomment#DefineType('sgml', g:tcommentInlineXML) +call tcomment#DefineType('sgml_block', g:tcommentBlockXML ) +call tcomment#DefineType('sgml_inline', g:tcommentInlineXML) +call tcomment#DefineType('sh', '# %s' ) +call tcomment#DefineType('slim', '/%s' ) +call tcomment#DefineType('sls', '# %s' ) +call tcomment#DefineType('smarty', '{* %s *}' ) +call tcomment#DefineType('spec', '# %s' ) +call tcomment#DefineType('sps', '* %s.' ) +call tcomment#DefineType('sps_block', "* %s." ) +call tcomment#DefineType('spss', '* %s.' ) +call tcomment#DefineType('spss_block', "* %s." ) +call tcomment#DefineType('sql', '-- %s' ) +call tcomment#DefineType('squid', '# %s' ) +call tcomment#DefineType('sshconfig', '# %s' ) +call tcomment#DefineType('sshdconfig', '# %s' ) +call tcomment#DefineType('st', '" %s "' ) +call tcomment#DefineType('tcl', '# %s' ) +call tcomment#DefineType('tex', '%% %s' ) +call tcomment#DefineType('tpl', '' ) +call tcomment#DefineType('typoscript', '# %s' ) +call tcomment#DefineType('upstart', '# %s' ) +call tcomment#DefineType('vhdl', '-- %s' ) +call tcomment#DefineType('verilog', '// %s' ) +call tcomment#DefineType('verilog_inline', g:tcommentInlineC ) +call tcomment#DefineType('verilog_block', g:tcommentBlockC ) +call tcomment#DefineType('verilog_systemverilog', '// %s' ) +call tcomment#DefineType('verilog_systemverilog_block', g:tcommentBlockC) +call tcomment#DefineType('verilog_systemverilog_inline', g:tcommentInlineC) +call tcomment#DefineType('viki', '%% %s' ) +call tcomment#DefineType('viki_3', '%%%%%% %s' ) +call tcomment#DefineType('viki_inline', '{cmt: %s}' ) +call tcomment#DefineType('vim', '" %s' ) +call tcomment#DefineType('vim_3', '""" %s' ) +call tcomment#DefineType('vimwiki', '%%%% %s' ) +call tcomment#DefineType('websec', '# %s' ) +call tcomment#DefineType('x86conf', '# %s' ) +call tcomment#DefineType('xml', g:tcommentInlineXML) +call tcomment#DefineType('xml_block', g:tcommentBlockXML ) +call tcomment#DefineType('xml_inline', g:tcommentInlineXML) +call tcomment#DefineType('xs', g:tcommentInlineC ) +call tcomment#DefineType('xs_block', g:tcommentBlockC ) +call tcomment#DefineType('xslt', g:tcommentInlineXML) +call tcomment#DefineType('xslt_block', g:tcommentBlockXML ) +call tcomment#DefineType('xslt_inline', g:tcommentInlineXML) +call tcomment#DefineType('yaml', '# %s' ) + " :doc: " A dictionary of NAME => COMMENT DEFINITION (see |tcomment#DefineType|) " that can be set in vimrc to override tcomment's default comment @@ -258,165 +533,6 @@ if exists('g:tcomment_types') unlet! s:name s:def endif -call tcomment#DefineType('aap', '# %s' ) -call tcomment#DefineType('ada', '-- %s' ) -call tcomment#DefineType('apache', '# %s' ) -call tcomment#DefineType('autoit', '; %s' ) -call tcomment#DefineType('asm', '; %s' ) -call tcomment#DefineType('awk', '# %s' ) -call tcomment#DefineType('catalog', '-- %s --' ) -call tcomment#DefineType('catalog_block', "--%s--\n " ) -call tcomment#DefineType('cpp', '// %s' ) -call tcomment#DefineType('cpp_inline', g:tcommentInlineC ) -call tcomment#DefineType('cpp_block', g:tcommentBlockC ) -call tcomment#DefineType('css', '/* %s */' ) -call tcomment#DefineType('css_inline', g:tcommentInlineC ) -call tcomment#DefineType('css_block', g:tcommentBlockC ) -call tcomment#DefineType('c', g:tcommentLineC ) -call tcomment#DefineType('c_inline', g:tcommentInlineC ) -call tcomment#DefineType('c_block', g:tcommentBlockC ) -call tcomment#DefineType('cfg', '# %s' ) -call tcomment#DefineType('clojure', {'commentstring': '; %s', 'count': 2}) -call tcomment#DefineType('clojure_inline', '; %s' ) -call tcomment#DefineType('clojurescript', ';; %s' ) -call tcomment#DefineType('clojurescript_inline', '; %s' ) -call tcomment#DefineType('coffee', '# %s' ) -call tcomment#DefineType('conf', '# %s' ) -call tcomment#DefineType('conkyrc', '# %s' ) -call tcomment#DefineType('crontab', '# %s' ) -call tcomment#DefineType('cs', '// %s' ) -call tcomment#DefineType('cs_inline', g:tcommentInlineC ) -call tcomment#DefineType('cs_block', g:tcommentBlockC ) -call tcomment#DefineType('debsources', '# %s' ) -call tcomment#DefineType('debcontrol', '# %s' ) -call tcomment#DefineType('desktop', '# %s' ) -call tcomment#DefineType('dnsmasq', '# %s' ) -call tcomment#DefineType('docbk', '' ) -call tcomment#DefineType('docbk_inline', g:tcommentInlineXML) -call tcomment#DefineType('docbk_block', g:tcommentBlockXML ) -call tcomment#DefineType('dosbatch', 'rem %s' ) -call tcomment#DefineType('dosini', '; %s' ) -call tcomment#DefineType('dsl', '; %s' ) -call tcomment#DefineType('dylan', '// %s' ) -call tcomment#DefineType('eiffel', '-- %s' ) -call tcomment#DefineType('erlang', '%%%% %s' ) -call tcomment#DefineType('eruby', '<%%# %s' ) -call tcomment#DefineType('fstab', '# %s' ) -call tcomment#DefineType('gitcommit', '# %s' ) -call tcomment#DefineType('gitignore', '# %s' ) -call tcomment#DefineType('gtkrc', '# %s' ) -call tcomment#DefineType('go', '// %s' ) -call tcomment#DefineType('go_inline', g:tcommentInlineC ) -call tcomment#DefineType('go_block', g:tcommentBlockC ) -call tcomment#DefineType('groovy', '// %s' ) -call tcomment#DefineType('groovy_inline', g:tcommentInlineC ) -call tcomment#DefineType('groovy_block', g:tcommentBlockC ) -call tcomment#DefineType('groovy_doc_block', g:tcommentBlockC2 ) -call tcomment#DefineType('haml', '-# %s' ) -call tcomment#DefineType('haskell', '-- %s' ) -call tcomment#DefineType('haskell_block', "{-%s-}\n " ) -call tcomment#DefineType('haskell_inline', '{- %s -}' ) -call tcomment#DefineType('html', '' ) -call tcomment#DefineType('html_inline', g:tcommentInlineXML) -call tcomment#DefineType('html_block', g:tcommentBlockXML ) -call tcomment#DefineType('htmldjango', '{# %s #}' ) -call tcomment#DefineType('htmldjango_block', "{%% comment %%}%s{%% endcomment %%}\n ") -call tcomment#DefineType('ini', '; %s' ) " php ini (/etc/php5/...) -call tcomment#DefineType('io', '// %s' ) -call tcomment#DefineType('jasmine', '# %s' ) -call tcomment#DefineType('javaScript', '// %s' ) -call tcomment#DefineType('javaScript_inline', g:tcommentInlineC ) -call tcomment#DefineType('javaScript_block', g:tcommentBlockC ) -call tcomment#DefineType('javascript', '// %s' ) -call tcomment#DefineType('javascript_inline', g:tcommentInlineC ) -call tcomment#DefineType('javascript_block', g:tcommentBlockC ) -call tcomment#DefineType('java', '/* %s */' ) -call tcomment#DefineType('java_inline', g:tcommentInlineC ) -call tcomment#DefineType('java_block', g:tcommentBlockC ) -call tcomment#DefineType('java_doc_block', g:tcommentBlockC2 ) -call tcomment#DefineType('jproperties', '# %s' ) -call tcomment#DefineType('lisp', '; %s' ) -call tcomment#DefineType('lynx', '# %s' ) -call tcomment#DefineType('matlab', '%% %s' ) -call tcomment#DefineType('m4', 'dnl %s' ) -call tcomment#DefineType('mail', '> %s' ) -call tcomment#DefineType('monkey', ''' %s' ) -call tcomment#DefineType('msidl', '// %s' ) -call tcomment#DefineType('msidl_block', g:tcommentBlockC ) -call tcomment#DefineType('nginx', '# %s' ) -call tcomment#DefineType('nroff', '.\\" %s' ) -call tcomment#DefineType('nsis', '# %s' ) -call tcomment#DefineType('objc', '/* %s */' ) -call tcomment#DefineType('objc_inline', g:tcommentInlineC ) -call tcomment#DefineType('objc_block', g:tcommentBlockC ) -call tcomment#DefineType('ocaml', '(* %s *)' ) -call tcomment#DefineType('ocaml_inline', '(* %s *)' ) -call tcomment#DefineType('ocaml_block', "(*%s*)\n " ) -call tcomment#DefineType('pac', '// %s' ) -call tcomment#DefineType('pascal', '(* %s *)' ) -call tcomment#DefineType('pascal_inline', '(* %s *)' ) -call tcomment#DefineType('pascal_block', "(*%s*)\n " ) -call tcomment#DefineType('perl', '# %s' ) -call tcomment#DefineType('perl_block', "=cut%s=cut" ) -call tcomment#DefineType('php', {'commentstring_rx': '\%%(//\|#\) %s', 'commentstring': '// %s'}) -call tcomment#DefineType('php_inline', g:tcommentInlineC ) -call tcomment#DefineType('php_block', g:tcommentBlockC ) -call tcomment#DefineType('php_2_block', g:tcommentBlockC2 ) -call tcomment#DefineType('po', '# %s' ) -call tcomment#DefineType('prolog', '%% %s' ) -call tcomment#DefineType('puppet', '# %s' ) -call tcomment#DefineType('python', '# %s' ) -call tcomment#DefineType('rc', '// %s' ) -call tcomment#DefineType('readline', '# %s' ) -call tcomment#DefineType('resolv', '# %s' ) -call tcomment#DefineType('robots', '# %s' ) -call tcomment#DefineType('ruby', '# %s' ) -call tcomment#DefineType('ruby_3', '### %s' ) -call tcomment#DefineType('ruby_block', "=begin rdoc%s=end") -call tcomment#DefineType('ruby_nodoc_block', "=begin%s=end" ) -call tcomment#DefineType('r', '# %s' ) -call tcomment#DefineType('samba', '# %s' ) -call tcomment#DefineType('sbs', "' %s" ) -call tcomment#DefineType('scheme', '; %s' ) -call tcomment#DefineType('scss', '// %s' ) -call tcomment#DefineType('scss_inline', g:tcommentInlineC ) -call tcomment#DefineType('scss_block', g:tcommentBlockC ) -call tcomment#DefineType('sed', '# %s' ) -call tcomment#DefineType('sgml', '' ) -call tcomment#DefineType('sgml_inline', g:tcommentInlineXML) -call tcomment#DefineType('sgml_block', g:tcommentBlockXML ) -call tcomment#DefineType('sh', '# %s' ) -call tcomment#DefineType('smarty', '{* %s *}' ) -call tcomment#DefineType('spec', '# %s' ) -call tcomment#DefineType('sps', '* %s.' ) -call tcomment#DefineType('sps_block', "* %s." ) -call tcomment#DefineType('spss', '* %s.' ) -call tcomment#DefineType('spss_block', "* %s." ) -call tcomment#DefineType('sql', '-- %s' ) -call tcomment#DefineType('squid', '# %s' ) -call tcomment#DefineType('st', '" %s "' ) -call tcomment#DefineType('tcl', '# %s' ) -call tcomment#DefineType('tex', '%% %s' ) -call tcomment#DefineType('tpl', '' ) -call tcomment#DefineType('typoscript', '# %s' ) -call tcomment#DefineType('vhdl', '-- %s' ) -call tcomment#DefineType('viki', '%% %s' ) -call tcomment#DefineType('viki_3', '%%%%%% %s' ) -call tcomment#DefineType('viki_inline', '{cmt: %s}' ) -call tcomment#DefineType('vim', '" %s' ) -call tcomment#DefineType('vim_3', '""" %s' ) -call tcomment#DefineType('websec', '# %s' ) -call tcomment#DefineType('x86conf', '# %s' ) -call tcomment#DefineType('xml', '' ) -call tcomment#DefineType('xml_inline', g:tcommentInlineXML) -call tcomment#DefineType('xml_block', g:tcommentBlockXML ) -call tcomment#DefineType('xs', '// %s' ) -call tcomment#DefineType('xs_block', g:tcommentBlockC ) -call tcomment#DefineType('xslt', '' ) -call tcomment#DefineType('xslt_inline', g:tcommentInlineXML) -call tcomment#DefineType('xslt_block', g:tcommentBlockXML ) -call tcomment#DefineType('yaml', '# %s' ) - function! s:DefaultValue(option) exec 'let '. a:option .' = &'. a:option @@ -426,11 +542,12 @@ function! s:DefaultValue(option) return default endf -let s:defaultComments = s:DefaultValue('comments') -let s:defaultCommentString = s:DefaultValue('commentstring') -let s:nullCommentString = '%s' -" tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...) +let s:default_comments = s:DefaultValue('comments') +let s:default_comment_string = s:DefaultValue('commentstring') +let s:null_comment_string = '%s' + +" tcomment#Comment(line1, line2, ?comment_mode, ?comment_anyway, ?args...) " args... are either: " 1. a list of key=value pairs where known keys are (see also " |g:tcommentOptions|): @@ -438,7 +555,8 @@ let s:nullCommentString = '%s' " count=N ... Repeat the comment string N times " col=N ... Start the comment at column N (in block " mode; must be smaller than |indent()|) -" mode=STRING ... See the notes below on the "commentMode" argument +" mode=STRING ... See the notes below on the "comment_mode" argument +" mode_extra=STRING ... Add to comment_mode " begin=STRING ... Comment prefix " end=STRING ... Comment postfix " middle=STRING ... Middle line comments in block mode @@ -446,17 +564,29 @@ let s:nullCommentString = '%s' " that should be multiplied by "count" " rxend=N ... The above for "end" " rxmid=N ... The above for "middle" +" mixedindent=BOOL ... If true, allow use of mixed +" characters for indentation " commentstring_rx ... A regexp format string that matches " commented lines (no new groups may be " introduced, the |regexp| is |\V|; % have " to be doubled); "commentstring", "begin" " and optionally "end" must be defined or " deducible. +" whitespace ... Define whether commented text is +" surrounded with whitespace; if +" both ... surround with whitespace (default) +" left ... keep whitespace on the left +" right... keep whitespace on the right +" no ... don't use whitespace +" strip_whitespace ... Strip trailing whitespace: if 1 +" (default), strip from empty lines only, +" if 2, always strip whitespace; if 0, +" don't strip any whitespace " 2. 1-2 values for: ?commentPrefix, ?commentPostfix " 3. a dictionary (internal use only) " -" commentMode: -" G ... guess the value of commentMode +" comment_mode (see also ¦g:tcommentModeExtra¦): +" G ... guess the value of comment_mode " B ... block (use extra lines for the comment markers) " i ... maybe inline, guess " I ... inline @@ -466,18 +596,49 @@ let s:nullCommentString = '%s' " By default, each line in range will be commented by adding the comment " prefix and postfix. function! tcomment#Comment(beg, end, ...) - let commentMode = (a:0 >= 1 ? a:1 : 'G') . g:tcommentModeExtra - let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0 - " TLogVAR a:beg, a:end, commentMode, commentAnyway + let comment_mode0 = s:AddModeExtra((a:0 >= 1 ? a:1 : 'G'), g:tcommentModeExtra, a:beg, a:end) + let comment_mode = comment_mode0 + let comment_anyway = a:0 >= 2 ? (a:2 == '!') : 0 + " TLogVAR a:beg, a:end, comment_mode, comment_anyway " save the cursor position - let s:current_pos = getpos('.') - let cursor_pos = getpos("'>") - let s:cursor_pos = [] - if commentMode =~# 'i' - let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g') + if exists('w:tcomment_pos') + let s:current_pos = copy(w:tcomment_pos) + else + let s:current_pos = getpos('.') + endif + " echom "DBG current_pos=" string(s:current_pos) + let cursor_pos = getpos("'>") + " TLogVAR cursor_pos + let s:cursor_pos = [] + if comment_mode =~# 'i' + let blnum = line("'<") + if blnum == line("'>") + if virtcol('.') <= indent(blnum) + let i_mode = 'G' + else + let i_mode = 'I' + endif + else + let i_mode = 'G' + endif + let comment_mode = substitute(comment_mode, '\Ci', i_mode, 'g') + " TLogVAR 1, comment_mode + endif + let [lbeg, cbeg, lend, cend] = s:GetStartEnd(a:beg, a:end, comment_mode) + " TLogVAR lbeg, cbeg, lend, cend, virtcol('$') + if comment_mode ==? 'I' && comment_mode0 =~# 'i' && lbeg == lend && cend >= virtcol('$') - 1 + if cbeg <= 1 + let comment_mode = 'G' + else + let comment_mode = 'R' + endif + " TLogVAR comment_mode + endif + if exists('s:temp_options') && has_key(s:temp_options, 'mode_extra') + let comment_mode = s:AddModeExtra(comment_mode, s:temp_options.mode_extra, lbeg, lend) + " TLogVAR comment_mode + unlet s:temp_options.mode_extra endif - let [lbeg, cbeg, lend, cend] = s:GetStartEnd(a:beg, a:end, commentMode) - " TLogVAR commentMode, lbeg, cbeg, lend, cend " get the correct commentstring let cdef = copy(g:tcommentOptions) " TLogVAR 1, cdef @@ -489,8 +650,10 @@ function! tcomment#Comment(beg, end, ...) call extend(cdef, a:3) " TLogVAR 3, cdef else - call extend(cdef, s:GetCommentDefinition(lbeg, lend, commentMode)) - " TLogVAR 4, cdef + let cdef0 = s:GetCommentDefinition(lbeg, lend, comment_mode) + " TLogVAR 4.1, cdef, cdef0 + call extend(cdef, cdef0) + " TLogVAR 4.2, cdef let ax = 3 if a:0 >= 3 && a:3 != '' && stridx(a:3, '=') == -1 let ax = 4 @@ -502,7 +665,7 @@ function! tcomment#Comment(beg, end, ...) endif " TLogVAR ax, a:0, a:000 if a:0 >= ax - let cdef = extend(cdef, s:ParseArgs(lbeg, lend, commentMode, a:000[ax - 1 : -1])) + let cdef = extend(cdef, s:ParseArgs(lbeg, lend, comment_mode, a:000[ax - 1 : -1])) " TLogVAR 5, cdef endif if !empty(get(cdef, 'begin', '')) || !empty(get(cdef, 'end', '')) @@ -510,15 +673,25 @@ function! tcomment#Comment(beg, end, ...) \ . '%s' \ . s:EncodeCommentPart(get(cdef, 'end', '')) endif - let commentMode = cdef.mode + let comment_mode = cdef.mode + " TLogVAR 2, comment_mode + endif + if empty(comment_mode) + echohl WarningMsg + echo "TComment: Comment mode is not supported for the current filetype" + echohl NONE + return endif if exists('s:temp_options') - let cdef = s:ExtendCDef(lbeg, lend, commentMode, cdef, s:temp_options) - " TLogVAR cdef + let cdef = s:ExtendCDef(lbeg, lend, comment_mode, cdef, s:temp_options) + " TLogVAR 6, cdef " echom "DBG s:temp_options" string(s:temp_options) unlet s:temp_options endif - " TLogVAR cdef + " TLogVAR 7, cdef + if has_key(cdef, 'whitespace') + call s:SetWhitespaceMode(cdef) + endif if !empty(filter(['count', 'cbeg', 'cend', 'cmid'], 'has_key(cdef, v:val)')) call s:RepeatCommentstring(cdef) endif @@ -527,66 +700,111 @@ function! tcomment#Comment(beg, end, ...) " TLogVAR cms0 " make whitespace optional; this conflicts with comments that require some " whitespace - let cmtCheck = substitute(cms0, '\([ ]\)', '\1\\?', 'g') + let cmt_check = substitute(cms0, '\([ ]\)', '\1\\?', 'g') " turn commentstring into a search pattern - let cmtCheck = printf(cmtCheck, '\(\_.\{-}\)') - " set commentMode and indentStr - let [indentStr, uncomment] = s:CommentDef(lbeg, lend, cmtCheck, commentMode, cbeg, cend) - " TLogVAR indentStr, uncomment - let col = get(cdef, 'col', -1) - if col >= 0 - let col -= 1 - let indent = len(indentStr) - if col > indent - let cms0 = repeat(' ', col - indent) . cms0 - " TLogVAR cms0 - else - let indentStr = repeat(' ', col) - endif - endif - if commentAnyway + " TLogVAR cmt_check + let cmt_check = printf(cmt_check, '\(\_.\{-}\)') + " TLogVAR cdef, cmt_check + let s:cdef = cdef + " set comment_mode + let [lbeg, lend, uncomment] = s:CommentDef(lbeg, lend, cmt_check, comment_mode, cbeg, cend) + " TLogVAR lbeg, lend, cbeg, cend, uncomment + " echom "DBG" string(s:cdef) + let cbeg = get(s:cdef, 'col', cbeg) + " TLogVAR cbeg + if comment_anyway let uncomment = 0 endif " go - if commentMode =~# 'B' + " TLogVAR comment_mode + if comment_mode =~# 'B' " We want a comment block - call s:CommentBlock(lbeg, lend, uncomment, cmtCheck, cdef, indentStr) + call s:CommentBlock(lbeg, lend, cbeg, cend, comment_mode, uncomment, cmt_check, s:cdef) else - " call s:CommentLines(lbeg, lend, cbeg, cend, uncomment, cmtCheck, cms0, indentStr) " We want commented lines " final search pattern for uncommenting - let cmtCheck = escape('\V\^\(\s\{-}\)'. cmtCheck .'\$', '"/\') + let cmt_check = '\V\^\(\s\{-}\)'. cmt_check .'\$' + " let cmt_check = escape(cmt_check, '"/\') " final pattern for commenting - let cmtReplace = s:GetCommentReplace(cdef, cms0) - " TLogVAR cmtReplace - let s:cdef = cdef - let cmd = lbeg .','. lend .'s/\V'. - \ s:StartPosRx(commentMode, lbeg, cbeg) . indentStr .'\zs\(\_.\{-}\)'. s:EndPosRx(commentMode, lend, cend) .'/'. - \ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge' - " TLogVAR cmd - exec cmd - call histdel('search', -1) - unlet s:cdef + let cmt_replace = s:GetCommentReplace(s:cdef, cms0) + " TLogVAR cmt_replace + " TLogVAR comment_mode, lbeg, cbeg, lend, cend + let s:processline_lnum = lbeg + let end_rx = s:EndPosRx(comment_mode, lend, cend) + let postfix_rx = end_rx == '\$' ? '' : '\.\*\$' + let prefix_rx = '\^\.\{-}' . s:StartPosRx(comment_mode, lbeg, cbeg) + let comment_rx = '\V' + \ . '\('. prefix_rx . '\)' + \ .'\(' + \ .'\(\_.\{-}\)' + \ . end_rx + \ .'\)' + \ .'\(' . postfix_rx . '\)' + " TLogVAR comment_rx, prefix_rx, end_rx, postfix_rx + " let @x = comment_rx " DBG + for lnum in range(lbeg, lend) + let line0 = getline(lnum) + " TLogVAR line0 + let lmatch = matchlist(line0, comment_rx) + " TLogVAR lmatch + if empty(lmatch) && g:tcomment#blank_lines >= 2 + let lline0 = s:Strdisplaywidth(line0) + " TLogVAR lline0, cbeg + if lline0 < cbeg + let line0 = line0 . repeat(' ', cbeg - lline0) + let lmatch = [line0, line0, '', '', ''] + " TLogVAR 'padded', line0, lmatch + endif + endif + if !empty(lmatch) + let part1 = s:ProcessLine(uncomment, lmatch[2], cmt_check, cmt_replace) + " TLogVAR part1 + let line1 = lmatch[1] . part1 . lmatch[4] + if uncomment && g:tcomment#rstrip_on_uncomment > 0 + if g:tcomment#rstrip_on_uncomment == 2 || line1 !~ '\S' + let line1 = substitute(line1, '\s\+$', '', '') + endif + endif + " TLogVAR line1 + call setline(lnum, line1) + endif + endfor endif " reposition cursor - " TLogVAR commentMode + " TLogVAR 3, comment_mode + " echom "DBG s:cursor_pos" string(s:cursor_pos) if !empty(s:cursor_pos) let cursor_pos = s:cursor_pos endif - if commentMode =~ '>' + if comment_mode =~ '>' call setpos('.', cursor_pos) - if commentMode !~ 'i' && commentMode =~ '>>' + if comment_mode !~ 'i' && comment_mode =~ '>>' norm! l^ endif - elseif commentMode =~ '#' + elseif comment_mode =~ '#' call setpos('.', cursor_pos) + if exists('w:tcomment_pos') + let w:tcomment_pos = cursor_pos + endif else call setpos('.', s:current_pos) endif - unlet s:cursor_pos s:current_pos + unlet! s:cursor_pos s:current_pos s:cdef endf +if v:version >= 703 + function! s:Strdisplaywidth(...) "{{{3 + return call('strdisplaywidth', a:000) + endf +else + function! s:Strdisplaywidth(string, ...) "{{{3 + " NOTE: Col argument is ignored + return strlen(substitute(a:string, ".", "x", "g")) + endf +endif + + function! tcomment#SetOption(name, arg) "{{{3 " TLogVAR a:name, a:arg if !exists('s:temp_options') @@ -604,37 +822,101 @@ function! tcomment#SetOption(name, arg) "{{{3 endf -function! s:GetStartEnd(beg, end, commentMode) "{{{3 - " TLogVAR a:beg, a:end, a:commentMode +function! s:GetStartEnd(beg, end, comment_mode) "{{{3 + " TLogVAR a:beg, a:end, a:comment_mode if type(a:beg) == 3 let [lbeg, cbeg] = a:beg - let [lend, cend] = a:end + let [lend, cend] = a:end else let lbeg = a:beg let lend = a:end - let commentMode = a:commentMode - " TLogVAR commentMode - if commentMode =~# 'R' - let cbeg = col('.') - let cend = 0 - let commentMode = substitute(commentMode, '\CR', 'G', 'g') - elseif commentMode =~# 'I' - let cbeg = col("'<") + let comment_mode = a:comment_mode + " TLogVAR comment_mode + if comment_mode =~# 'R' + let cbeg = virtcol('.') + let cend = virtcol('$') + let comment_mode = substitute(comment_mode, '\CR', 'G', 'g') + " TLogVAR 'R', cbeg, cend, comment_mode + elseif comment_mode =~# 'I' + let cbeg = virtcol("'<") if cbeg == 0 - let cbeg = col('.') + let cbeg = virtcol('.') endif - let cend = col("'>") - if cend < col('$') && (commentMode =~# 'o' || &selection == 'inclusive') + let cend = virtcol("'>") + if cend < virtcol('$') && (comment_mode =~# 'o' || &selection == 'inclusive') let cend += 1 - " TLogVAR cend, col('$') + " TLogVAR cend, virtcol('$') endif + " TLogVAR 'I', cbeg, cend, comment_mode else - let cbeg = 0 + let cbeg = -1 let cend = 0 + for lnum in range(a:beg, a:end) + if getline(lnum) =~ '\S' + let indentwidth = indent(lnum) + " TLogVAR cbeg, lnum, indentwidth, getline(lnum) + if cbeg == -1 || indentwidth < cbeg + let cbeg = indentwidth + endif + endif + endfor + if cbeg == -1 + let cbeg = 0 + endif endif endif " TLogVAR lbeg, cbeg, lend, cend - return [lbeg, cbeg, lend, cend] + if lend < lbeg || (lend == lbeg && cend > 0 && cend < cbeg) + return [lend, cend, lbeg, cbeg] + else + return [lbeg, cbeg, lend, cend] + endif +endf + + +function! s:SetWhitespaceMode(cdef) "{{{3 + let mode = a:cdef.whitespace + let cms = s:BlockGetCommentString(a:cdef) + let mid = s:BlockGetMiddleString(a:cdef) + let cms0 = cms + let mid0 = mid + " TLogVAR mode, cms, mid + if mode =~ '^\(n\%[o]\|l\%[eft]\|r\%[ight]\)$' + " Remove whitespace on the left + if mode =~ '^n\%[o]$' || mode =~ '^r\%[ight]$' + let cms = substitute(cms, '\s\+\ze%\@= 1 ? a:1 : '' + let type = a:type + let comment_mode = a:0 >= 1 ? a:1 : '' let bang = a:0 >= 2 ? a:2 : '' - " TLogVAR a:type, commentMode, bang - if !exists('w:tcommentPos') - let w:tcommentPos = getpos(".") + " TLogVAR type, comment_mode, bang + if !exists('w:tcomment_pos') + let w:tcomment_pos = getpos(".") endif let sel_save = &selection set selection=inclusive let reg_save = @@ - " let pos = getpos('.') try - if a:type == 'line' + if type == 'line' silent exe "normal! '[V']" - let commentMode1 = 'G' - elseif a:type == 'block' + let comment_mode1 = 'G' + elseif type == 'block' silent exe "normal! `[\`]" - let commentMode1 = 'I' - elseif a:type == 'char' && !g:tcomment#ignore_char_type + let comment_mode1 = 'I' + elseif type == 'char' silent exe "normal! `[v`]" - let commentMode1 = 'I' + let comment_mode1 = 'I' else silent exe "normal! `[v`]" - let commentMode1 = 'i' + let comment_mode1 = 'i' endif - if empty(commentMode) - let commentMode = commentMode1 + if empty(comment_mode) + let comment_mode = comment_mode1 endif let lbeg = line("'[") let lend = line("']") - let cbeg = col("'[") - let cend = col("']") - " TLogVAR lbeg, lend, cbeg, cend - " echom "DBG tcomment#Operator" lbeg col("'[") col("'<") lend col("']") col("'>") + let cend = virtcol("']") + if type == 'char' + if lbeg == lend && cend >= virtcol('$') - 1 + let comment_mode = 'R' + elseif g:tcomment#ignore_char_type && lbeg != lend + silent exe "normal! '[V']" + let cend = virtcol("']") + let comment_mode = 'G' + let type = 'line' + endif + endif + let cbeg = virtcol("'[") + " TLogVAR comment_mode, comment_mode1, lbeg, lend, cbeg, cend, virtcol('$') + " TLogVAR comment_mode + " echom "DBG tcomment#Operator" lbeg virtcol("'[") virtcol("'<") lend virtcol("']") virtcol("'>") norm!  - let commentMode .= g:tcommentOpModeExtra - if a:type =~ 'line\|block' || g:tcomment#ignore_char_type - call tcomment#Comment(lbeg, lend, commentMode.'o', bang) + let comment_mode = s:AddModeExtra(comment_mode, g:tcommentOpModeExtra, lbeg, lend) + " TLogVAR comment_mode, type + " if type =~ 'line\|block' || g:tcomment#ignore_char_type + " if comment_mode =~# '[R]' + " call tcomment#Comment([lbeg, cbeg], [lend, cend], comment_mode.'o', bang) + " elseif type =~ 'line\|block' || g:tcomment#ignore_char_type + if type =~ 'line\|block' + call tcomment#Comment(lbeg, lend, comment_mode.'o', bang) else - call tcomment#Comment([lbeg, cbeg], [lend, cend], commentMode.'o', bang) + call tcomment#Comment([lbeg, cbeg], [lend, cend], comment_mode.'o', bang) endif finally let &selection = sel_save let @@ = reg_save - if g:tcommentOpModeExtra !~ '>' - " TLogVAR pos - " call setpos('.', pos) - if exists('w:tcommentPos') - call setpos('.', w:tcommentPos) - unlet! w:tcommentPos + " TLogVAR g:tcommentOpModeExtra + if g:tcommentOpModeExtra !~ '[#>]' + if exists('w:tcomment_pos') + " TLogVAR w:tcomment_pos + if w:tcomment_pos != getpos('.') + call setpos('.', w:tcomment_pos) + endif + unlet! w:tcomment_pos else echohl WarningMsg - echom "TComment: w:tcommentPos wasn't set. Please report this to the plugin author" + echom "TComment: w:tcomment_pos wasn't set. Please report this to the plugin author" echohl NONE endif endif @@ -752,59 +1062,62 @@ endf function! tcomment#OperatorLine(type) "{{{3 - call tcomment#Operator(a:type, 'G') + " TLogVAR a:type + call tcomment#Operator('line', 'G') endf function! tcomment#OperatorAnyway(type) "{{{3 + " TLogVAR a:type call tcomment#Operator(a:type, '', '!') endf function! tcomment#OperatorLineAnyway(type) "{{{3 - call tcomment#Operator(a:type, 'G', '!') + " TLogVAR a:type + call tcomment#Operator('line', 'G', '!') endf -" :display: tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...) +" :display: tcomment#CommentAs(beg, end, comment_anyway, filetype, ?args...) " Where args is either: " 1. A count NUMBER " 2. An args list (see the notes on the "args" argument of " |tcomment#Comment()|) " comment text as if it were of a specific filetype -function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...) +function! tcomment#CommentAs(beg, end, comment_anyway, filetype, ...) if a:filetype =~ '_block$' - let commentMode = 'B' + let comment_mode = 'B' let ft = substitute(a:filetype, '_block$', '', '') elseif a:filetype =~ '_inline$' - let commentMode = 'I' + let comment_mode = 'I' let ft = substitute(a:filetype, '_inline$', '', '') else - let commentMode = 'G' + let comment_mode = 'G' let ft = a:filetype endif if a:0 >= 1 if type(a:1) == 0 let cdef = {'count': a:0 >= 1 ? a:1 : 1} else - let cdef = s:ParseArgs(a:beg, a:end, commentMode, a:000) + let cdef = s:ParseArgs(a:beg, a:end, comment_mode, a:000) endif else let cdef = {} endif " echom "DBG" string(cdef) - call extend(cdef, s:GetCommentDefinitionForType(a:beg, a:end, commentMode, ft)) - keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, cdef) + call extend(cdef, s:GetCommentDefinitionForType(a:beg, a:end, comment_mode, ft)) + keepjumps call tcomment#Comment(a:beg, a:end, comment_mode, a:comment_anyway, cdef) endf " collect all known comment types " :nodoc: function! tcomment#CollectFileTypes() - if s:typesDirty + if s:types_dirty let s:types = keys(s:definitions) - let s:typesRx = '\V\^\('. join(s:types, '\|') .'\)\(\u\.\*\)\?\$' - let s:typesDirty = 0 + let s:types_rx = '\V\^\('. join(s:types, '\|') .'\)\(\u\.\*\)\?\$' + let s:types_dirty = 0 endif endf @@ -829,8 +1142,14 @@ function! tcomment#Complete(ArgLead, CmdLine, CursorPos) "{{{3 endf +let s:first_completion = 0 + " :nodoc: function! tcomment#CompleteArgs(ArgLead, CmdLine, CursorPos) "{{{3 + if v:version < 703 && !s:first_completion + redraw + let s:first_completion = 1 + endif let completions = ['as=', 'col=', 'count=', 'mode=', 'begin=', 'end=', 'rxbeg=', 'rxend=', 'rxmid='] if !empty(a:ArgLead) if a:ArgLead =~ '^as=' @@ -848,11 +1167,11 @@ function! s:EncodeCommentPart(string) endf -function! s:GetCommentDefinitionForType(beg, end, commentMode, filetype) "{{{3 - let cdef = s:GetCommentDefinition(a:beg, a:end, a:commentMode, a:filetype) +function! s:GetCommentDefinitionForType(beg, end, comment_mode, filetype) "{{{3 + let cdef = s:GetCommentDefinition(a:beg, a:end, a:comment_mode, a:filetype) " TLogVAR cdef let cms = cdef.commentstring - let commentMode = cdef.mode + let comment_mode = cdef.mode let pre = substitute(cms, '%\@= 1 ? a:1 : '' + " TLogVAR ft if ft != '' - let cdef = s:GetCustomCommentString(ft, a:commentMode) + let cdef = s:GuessCustomCommentString(ft, a:comment_mode) else - let cdef = {'mode': a:commentMode} + let cdef = {'mode': a:comment_mode} endif " TLogVAR cdef let cms = get(cdef, 'commentstring', '') if empty(cms) - let filetype = s:Filetype() + let filetype = s:Filetype(ft) if exists('b:commentstring') let cms = b:commentstring " TLogVAR 1, cms - return s:GetCustomCommentString(filetype, a:commentMode, cms) + return s:GuessCustomCommentString(filetype, a:comment_mode, cms) elseif exists('b:commentStart') && b:commentStart != '' let cms = s:EncodeCommentPart(b:commentStart) .' %s' " TLogVAR 2, cms if exists('b:commentEnd') && b:commentEnd != '' let cms = cms .' '. s:EncodeCommentPart(b:commentEnd) endif - return s:GetCustomCommentString(filetype, a:commentMode, cms) - elseif g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. filetype) - \ && g:tcommentGuessFileType_{filetype} =~ '[^0]') - if g:tcommentGuessFileType_{filetype} == 1 - let altFiletype = '' - else - let altFiletype = g:tcommentGuessFileType_{filetype} - endif - " TLogVAR altFiletype - return s:GuessFileType(a:beg, a:end, a:commentMode, filetype, altFiletype) + return s:GuessCustomCommentString(filetype, a:comment_mode, cms) else - return s:GetCustomCommentString(filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode)) + let [use_guess_ft, altFiletype] = s:AltFiletype(ft) + " TLogVAR use_guess_ft, altFiletype + if use_guess_ft + return s:GuessFileType(a:beg, a:end, a:comment_mode, filetype, altFiletype) + else + let guess_cdef = s:GuessVimOptionsCommentString(a:comment_mode) + " TLogVAR guess_cdef + return s:GuessCustomCommentString(filetype, a:comment_mode, guess_cdef.commentstring, guess_cdef) + endif endif let cdef.commentstring = cms endif return cdef endf -function! s:StartPosRx(mode, line, col) - " TLogVAR a:mode, a:line, a:col - if a:mode =~# 'I' - return s:StartLineRx(a:line) . s:StartColRx(a:col) - else - return s:StartColRx(a:col) - endif -endf -function! s:EndPosRx(mode, line, col) - if a:mode =~# 'I' - return s:EndLineRx(a:line) . s:EndColRx(a:col) - else - return s:EndColRx(a:col) - endif -endf - -function! s:StartLineRx(pos) - return '\%'. a:pos .'l' -endf - -function! s:EndLineRx(pos) - return '\%'. a:pos .'l' -endf - -function! s:StartColRx(pos) - if a:pos == 0 - return '\^' - else - return '\%'. a:pos .'c' - endif -endf - -function! s:EndColRx(pos) - if a:pos == 0 - return '\$' - else - return '\%'. a:pos .'c' - endif -endf - -function! s:GetIndentString(line, start) - let start = a:start > 0 ? a:start - 1 : 0 - return substitute(strpart(getline(a:line), start), '\V\^\s\*\zs\.\*\$', '', '') -endf - -function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend) - let mdrx = '\V'. s:StartColRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndColRx(0) - " let mdrx = '\V'. s:StartPosRx(a:commentMode, a:beg, a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndPosRx(a:commentMode, a:end, 0) - let line = getline(a:beg) - if a:cstart != 0 && a:cend != 0 - let line = strpart(line, 0, a:cend - 1) - endif - let uncomment = (line =~ mdrx) - let indentStr = s:GetIndentString(a:beg, a:cstart) - let il = indent(a:beg) - let n = a:beg + 1 - while n <= a:end - if getline(n) =~ '\S' - let jl = indent(n) - if jl < il - let indentStr = s:GetIndentString(n, a:cstart) - let il = jl - endif - if a:commentMode =~# 'G' - if !(getline(n) =~ mdrx) - let uncomment = 0 - endif - endif - endif - let n = n + 1 - endwh - if a:commentMode =~# 'B' - let t = @t - try - silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"ty' - let uncomment = (@t =~ mdrx) - finally - let @t = t - endtry - endif - return [indentStr, uncomment] -endf - -function! s:ProcessedLine(uncomment, match, checkRx, replace) - " TLogVAR a:uncomment, a:match, a:checkRx, a:replace - if !(a:match =~ '\S' || g:tcommentBlankLines) - return a:match - endif - let ml = len(a:match) - if a:uncomment - let rv = substitute(a:match, a:checkRx, '\1\2', '') - let rv = s:UnreplaceInLine(rv) - else - let rv = s:ReplaceInLine(a:match) - let rv = printf(a:replace, rv) - endif - " TLogVAR rv - " let md = len(rv) - ml - if s:cdef.mode =~ '>' - let s:cursor_pos = getpos('.') - let s:cursor_pos[2] += len(rv) - elseif s:cdef.mode =~ '#' - if empty(s:cursor_pos) - let prefix_len = match(a:replace, '%\@ 702 || (v:version == 702 && has('patch407')) - let rv = escape(rv, "\r") - else - let rv = escape(rv, "\\r") - endif - " TLogVAR rv - " let rv = substitute(rv, '\n', '\\\n', 'g') +function! s:StartPosRx(comment_mode, line, col) + " TLogVAR a:comment_mode, a:line, a:col + " if a:comment_mode =~# 'I' + " return s:StartLineRx(a:line) . s:StartColRx(a:comment_mode, a:col) + " else + let rv = s:StartColRx(a:comment_mode, a:col) + " endif " TLogVAR rv return rv endf +function! s:EndPosRx(comment_mode, line, col) + " TLogVAR a:comment_mode, a:line, a:col + " if a:comment_mode =~# 'I' + " return s:EndLineRx(a:line) . s:EndColRx(a:col) + " else + return s:EndColRx(a:comment_mode, a:col) + " endif +endf + + +function! s:StartLineRx(pos) + return '\%'. a:pos .'l' +endf + + +function! s:EndLineRx(pos) + return '\%'. a:pos .'l' +endf + + +function! s:StartColRx(comment_mode, col, ...) + let mixedindent = a:0 >= 1 ? a:1 : get(s:cdef, 'mixedindent', 1) + " TLogVAR a:comment_mode, a:col, mixedindent + if a:comment_mode =~# '[IR]' + let col = mixedindent ? a:col - 1 : a:col + let c0 = 1 + else + let col = a:col + let c0 = 2 + endif + " TLogVAR col, c0, mixedindent + if col < c0 + return '\^' + elseif mixedindent + return '\%>'. col .'v' + else + return '\%'. col .'v' + endif +endf + + +function! s:EndColRx(comment_mode, pos) + " TLogVAR a:comment_mode, a:pos + if a:pos == 0 + return '\$' + else + if a:comment_mode =~? 'i' && a:comment_mode =~# 'o' + let mod = '>' + else + let mod = '' + endif + " TLogVAR &selection, mod + return '\%'. mod . a:pos .'v' + endif +endf + + +function! s:CommentDef(beg, end, checkRx, comment_mode, cbeg, cend) + " TLogVAR a:beg, a:end, a:checkRx, a:comment_mode, a:cbeg, a:cend + let beg = a:beg + let end = a:end + if get(s:cdef, 'mixedindent', 1) + let mdrx = '\V'. s:StartColRx(a:comment_mode, a:cbeg) .'\s\*' + let mdrx .= s:StartColRx(a:comment_mode, a:cbeg + 1, 0) .'\s\*' + else + let mdrx = '\V'. s:StartColRx(a:comment_mode, a:cbeg) .'\s\*' + endif + let mdrx .= a:checkRx .'\s\*'. s:EndColRx(a:comment_mode, 0) + " let mdrx = '\V'. s:StartPosRx(a:comment_mode, beg, a:cbeg) .'\s\*'. a:checkRx .'\s\*'. s:EndPosRx(a:comment_mode, end, 0) + " TLogVAR mdrx + let line = getline(beg) + if a:cbeg != 0 && a:cend != 0 + let line = strpart(line, 0, a:cend - 1) + endif + let uncomment = (line =~ mdrx) + " TLogVAR 1, uncomment, line + let n = beg + 1 + if a:comment_mode =~# 'G' + if uncomment + while n <= end + if getline(n) =~ '\S' + if !(getline(n) =~ mdrx) + let uncomment = 0 + " TLogVAR 2, uncomment + break + endif + endif + let n = n + 1 + endwh + endif + elseif a:comment_mode =~# 'B' + let t = @t + try + silent exec 'norm! '. beg.'G1|v'.end.'G$"ty' + if &selection == 'inclusive' && @t =~ '\n$' && len(@t) > 1 + let @t = @t[0 : -2] + endif + " TLogVAR @t, mdrx + let uncomment = (@t =~ mdrx) + " TLogVAR 3, uncomment + if !uncomment && a:comment_mode =~ 'o' + let mdrx1 = substitute(mdrx, '\\$$', '\\n\\$', '') + " TLogVAR mdrx1 + if @t =~ mdrx1 + let uncomment = 1 + " TLogVAR 4, uncomment + endif + endif + finally + let @t = t + endtry + endif + " TLogVAR 5, uncomment + return [beg, end, uncomment] +endf + + +function! s:ProcessLine(uncomment, match, checkRx, replace) + " TLogVAR a:uncomment, a:match, a:checkRx, a:replace + try + if !(g:tcomment#blank_lines > 0 || a:match =~ '\S') + return a:match + endif + if a:uncomment + let rv = substitute(a:match, a:checkRx, '\1\2', '') + let rv = s:UnreplaceInLine(rv) + else + let ml = len(a:match) + let rv = s:ReplaceInLine(a:match) + let rv = printf(a:replace, rv) + let strip_whitespace = get(s:cdef, 'strip_whitespace', 1) + if strip_whitespace == 2 || (strip_whitespace == 1 && ml == 0) + let rv = substitute(rv, '\s\+$', '', '') + endif + endif + " TLogVAR rv + " echom "DBG s:cdef.mode=" string(s:cdef.mode) "s:cursor_pos=" string(s:cursor_pos) + if s:cdef.mode =~ '>' + let s:cursor_pos = getpos('.') + let s:cursor_pos[2] += len(rv) + elseif s:cdef.mode =~ '#' + if empty(s:cursor_pos) || s:current_pos[1] == s:processline_lnum + let prefix = matchstr(a:replace, '^.*%\@ 702 || (v:version == 702 && has('patch407')) + let rv = escape(rv, "\r") + else + let rv = escape(rv, "\\r") + endif + " TLogVAR rv + " let rv = substitute(rv, '\n', '\\\n', 'g') + " TLogVAR rv + return rv + finally + let s:processline_lnum += 1 + endtry +endf + + function! s:ReplaceInLine(text) "{{{3 if has_key(s:cdef, 'replacements') - let text = a:text - " TLogVAR text - for [token, substitution] in items(s:cdef.replacements) - let text = substitute(text, '\V'. escape(token, '\'), substitution, 'g') - " TLogVAR token, substitution, text - endfor - " TLogVAR text - return text + let replacements = s:cdef.replacements + return s:DoReplacements(a:text, keys(replacements), values(replacements)) else return a:text endif @@ -1046,45 +1423,135 @@ endf function! s:UnreplaceInLine(text) "{{{3 if has_key(s:cdef, 'replacements') - let text = a:text - " TLogVAR text - for [substitution, token] in items(s:cdef.replacements) - " TLogVAR substitution, token - let text = substitute(text, '\V'. escape(token, '\'), substitution, 'g') - endfor - return text + let replacements = s:cdef.replacements + return s:DoReplacements(a:text, values(replacements), keys(replacements)) else return a:text endif endf -function! s:CommentBlock(beg, end, uncomment, checkRx, cdef, indentStr) - " TLogVAR a:beg, a:end, a:uncomment, a:checkRx, a:cdef, a:indentStr +function! s:DoReplacements(text, tokens, replacements) "{{{3 + if empty(a:tokens) + return a:text + else + let rx = '\V\('. join(map(a:tokens, 'escape(v:val, ''\'')'), '\|') .'\)' + let texts = split(a:text, rx .'\zs', 1) + let texts = map(texts, 's:InlineReplacement(v:val, rx, a:tokens, a:replacements)') + let text = join(texts, '') + return text + endif +endf + + +function! s:InlineReplacement(text, rx, tokens, replacements) "{{{3 + " TLogVAR a:text, a:rx, a:replacements + let matches = split(a:text, '\ze'. a:rx .'\$', 1) + if len(matches) == 1 + return a:text + else + let match = matches[-1] + let idx = index(a:tokens, match) + " TLogVAR matches, match, idx + if idx != -1 + let matches[-1] = a:replacements[idx] + " TLogVAR matches + return join(matches, '') + else + throw 'TComment: Internal error: cannot find '. string(match) .' in '. string(a:tokens) + endif + endif +endf + + +function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, uncomment, checkRx, cdef) + " TLogVAR a:beg, a:end, a:cbeg, a:cend, a:uncomment, a:checkRx, a:cdef + let indentStr = repeat(' ', a:cbeg) let t = @t let sel_save = &selection set selection=exclusive try silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td' + " TLogVAR @t let ms = s:BlockGetMiddleString(a:cdef) let mx = escape(ms, '\') + let cs = s:BlockGetCommentString(a:cdef) + let prefix = substitute(matchstr(cs, '^.*%\@ a:beg + let s:cursor_pos[1] -= prefix_lines + if s:cursor_pos[1] > a:end - postfix_lines + let s:cursor_pos[1] -= postfix_lines + endif + if s:cursor_pos[1] < 1 + let s:cursor_pos[1] = 1 + endif + endif + let prefix_len = s:Strdisplaywidth(mx) + let s:cursor_pos[2] -= prefix_len + if s:cursor_pos[2] < 1 + let s:cursor_pos[2] = 1 + endif + endif else - let cs = s:BlockGetCommentString(a:cdef) - let cs = a:indentStr . substitute(cs, '%\@'. indentlen .'v\zs' + " TLogVAR indentStr, indentlen, rx, @t, empty(@t) + if @t =~ '^\n\?$' + let lines = [indentStr . ms] + let cs .= "\n" + " TLogVAR 1, lines + else + for line in split(@t, '\n') + " TLogVAR 1, line + if lnum == 0 + let line = substitute(line, rx, ms, '') + else + let line = substitute(line, rx, mx, '') + endif + " TLogVAR 2, line + call add(lines, line) + let lnum += 1 + endfor + " TLogVAR 2, lines + endif + let @t = join(lines, "\n") + " TLogVAR 3, @t endif let @t = printf(cs, "\n". @t ."\n") + " TLogVAR 4, cs, @t, a:comment_mode + if a:comment_mode =~ '#' + let s:cursor_pos = copy(s:current_pos) + let s:cursor_pos[1] += len(substitute(prefix, "[^\n]", '', 'g')) + 1 + let prefix_len = s:Strdisplaywidth(mx) + let s:cursor_pos[2] += prefix_len + " echom "DBG s:current_pos=" string(s:current_pos) "s:cursor_pos=" string(s:cursor_pos) + endif endif silent norm! "tP finally @@ -1095,9 +1562,56 @@ endf function! s:Filetype(...) "{{{3 - let ft = a:0 >= 1 ? a:1 : &filetype - let ft = substitute(ft, '\..*$', '', '') - return ft + let ft = a:0 >= 1 && !empty(a:1) ? a:1 : &filetype + let pos = a:0 >= 2 ? a:2 : 0 + " TLogVAR ft, pos + let fts = split(ft, '^\@!\.') + " TLogVAR fts + " let ft = substitute(ft, '\..*$', '', '') + let rv = get(fts, pos, ft) + " TLogVAR fts, rv + if !exists('s:filetype_map_rx') + let fts_rx = '^'. join(map(keys(g:tcomment#filetype_map), 'escape(v:val, ''\'')'), '\|') .'$' + endif + " TLogVAR fts_rx + if rv =~ fts_rx + for [ft_rx, ftrv] in items(g:tcomment#filetype_map) + " TLogVAR ft_rx, ftrv + if rv =~ ft_rx + let rv = substitute(rv, ft_rx, ftrv, '') + " TLogVAR rv + break + endif + endfor + endif + return rv +endf + + +function! s:AltFiletype(filetype) "{{{3 + let filetype = empty(a:filetype) ? &filetype : a:filetype + " TLogVAR a:filetype, filetype + if g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. filetype) + \ && g:tcommentGuessFileType_{filetype} =~ '[^0]') + if g:tcommentGuessFileType_{filetype} == 1 + if filetype =~ '^.\{-}\..\+$' + let altFiletype = s:Filetype(filetype, 1) + else + let altFiletype = '' + endif + else + let altFiletype = g:tcommentGuessFileType_{filetype} + endif + " TLogVAR 1, altFiletype + return [1, altFiletype] + elseif filetype =~ '^.\{-}\..\+$' + let altFiletype = s:Filetype(filetype, 1) + " TLogVAR 2, altFiletype + return [1, altFiletype] + else + " TLogVAR 3, '' + return [0, ''] + endif endf @@ -1108,7 +1622,7 @@ endf " " beg ................ (default = line(".")) " end ................ (default = line(".")) -" commentMode ........ (default = "G") +" comment_mode ........ (default = "G") " filetype ........... (default = &filetype) " fallbackFiletype ... (default = "") " @@ -1121,28 +1635,37 @@ function! tcomment#GuessCommentType(...) "{{{3 let options = a:0 >= 1 ? a:1 : {} let beg = get(options, 'beg', line('.')) let end = get(options, 'end', line('.')) - let commentMode = get(options, 'commentMode', '') + let comment_mode = get(options, 'comment_mode', '') let filetype = get(options, 'filetype', &filetype) let fallbackFiletype = get(options, 'filetype', '') - return s:GuessFileType(beg, end, commentMode, filetype, fallbackFiletype) + return s:GuessFileType(beg, end, comment_mode, filetype, fallbackFiletype) endf " inspired by Meikel Brandmeyer's EnhancedCommentify.vim " this requires that a syntax names are prefixed by the filetype name -" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype) -function! s:GuessFileType(beg, end, commentMode, filetype, ...) - " TLogVAR a:beg, a:end, a:commentMode, a:filetype, a:000 +" s:GuessFileType(beg, end, comment_mode, filetype, ?fallbackFiletype) +function! s:GuessFileType(beg, end, comment_mode, filetype, ...) + " TLogVAR a:beg, a:end, a:comment_mode, a:filetype, a:000 + " TLogVAR cdef + let cdef0 = s:GuessCustomCommentString(a:filetype, a:comment_mode) if a:0 >= 1 && a:1 != '' - let cdef = s:GetCustomCommentString(a:1, a:commentMode) + let cdef = s:GuessCustomCommentString(a:1, a:comment_mode) + " TLogVAR 0, cdef + let cdef = extend(cdef, cdef0, 'keep') + " TLogVAR 1, cdef if empty(get(cdef, 'commentstring', '')) - let cdef.commentstring = s:GuessCurrentCommentString(a:commentMode) + let guess_cdef = s:GuessVimOptionsCommentString(a:comment_mode) + call extend(cdef, guess_cdef) endif + " TLogVAR 2, cdef else - let cdef = s:GetCustomCommentString(a:filetype, a:commentMode) + let cdef = cdef0 + " TLogVAR 3, cdef if !has_key(cdef, 'commentstring') - let cdef = {'commentstring': s:GuessCurrentCommentString(0), 'mode': s:CommentMode(a:commentMode, 'G')} + let cdef = s:GuessVimOptionsCommentString(a:comment_mode) endif + " TLogVAR 4, cdef endif let beg = a:beg let end = nextnonblank(a:end) @@ -1161,11 +1684,12 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...) let le = len(text) " TLogVAR m, le while m <= le - let syntaxName = s:GetSyntaxName(n, m) - " TLogVAR syntaxName, n, m - let ftypeMap = get(g:tcommentSyntaxMap, syntaxName, '') - " TLogVAR ftypeMap - if !empty(ftypeMap) && type(ftypeMap) == 4 + let syntax_name = s:GetSyntaxName(n, m) + " TLogVAR syntax_name, n, m + unlet! ftype_map + let ftype_map = get(g:tcommentSyntaxMap, syntax_name, '') + " TLogVAR ftype_map + if !empty(ftype_map) && type(ftype_map) == 4 if n < a:beg let key = 'prevnonblank' elseif n > a:end @@ -1173,39 +1697,39 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...) else let key = '' endif - if empty(key) || !has_key(ftypeMap, key) - let ftypeftype = get(ftypeMap, 'filetype', {}) - " TLogVAR ftypeMap, ftypeftype - unlet! ftypeMap - let ftypeMap = get(ftypeftype, a:filetype, '') + if empty(key) || !has_key(ftype_map, key) + let ftypeftype = get(ftype_map, 'filetype', {}) + " TLogVAR ftype_map, ftypeftype + unlet! ftype_map + let ftype_map = get(ftypeftype, a:filetype, '') else let mapft = '' - for mapdef in ftypeMap[key] + for mapdef in ftype_map[key] if strpart(text, m - 1) =~ '^'. mapdef.match let mapft = mapdef.filetype break endif endfor - unlet! ftypeMap + unlet! ftype_map if empty(mapft) - let ftypeMap = '' + let ftype_map = '' else - let ftypeMap = mapft + let ftype_map = mapft endif endif endif - if !empty(ftypeMap) - " TLogVAR ftypeMap - return s:GetCustomCommentString(ftypeMap, a:commentMode, cdef.commentstring) - elseif syntaxName =~ s:typesRx - let ft = substitute(syntaxName, s:typesRx, '\1', '') + if !empty(ftype_map) + " TLogVAR ftype_map + return s:GuessCustomCommentString(ftype_map, a:comment_mode, cdef.commentstring) + elseif syntax_name =~ s:types_rx + let ft = substitute(syntax_name, s:types_rx, '\1', '') " TLogVAR ft if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>' let m += 1 else - return s:GetCustomCommentString(ft, a:commentMode, cdef.commentstring) + return s:GuessCustomCommentString(ft, a:comment_mode, cdef.commentstring) endif - elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$' + elseif syntax_name == '' || syntax_name == 'None' || syntax_name =~ '^\u\+$' || syntax_name =~ '^\u\U*$' let m += 1 else break @@ -1219,118 +1743,211 @@ endf function! s:GetSyntaxName(lnum, col) "{{{3 - let syntaxName = synIDattr(synID(a:lnum, a:col, 1), 'name') + let syntax_name = synIDattr(synID(a:lnum, a:col, 1), 'name') if !empty(g:tcomment#syntax_substitute) for [rx, subdef] in items(g:tcomment#syntax_substitute) if !has_key(subdef, 'if') || eval(subdef.if) - let syntaxName = substitute(syntaxName, rx, subdef.sub, 'g') + let syntax_name = substitute(syntax_name, rx, subdef.sub, 'g') endif endfor endif - " TLogVAR syntaxName - return syntaxName + " TLogVAR syntax_name + return syntax_name endf -function! s:CommentMode(commentMode, newmode) "{{{3 - return substitute(a:commentMode, '\w\+', a:newmode, 'g') -endf - -function! s:GuessCurrentCommentString(commentMode) - " TLogVAR a:commentMode - let valid_cms = (match(&commentstring, '%\@= 1 ? a:1 : '' + let default_cdef = a:0 >= 2 ? a:2 : {} + let default_supports_comment_mode = get(default_cdef, 'comment_mode', custom_comment_mode) + " TLogVAR default, default_supports_comment_mode + if comment_mode =~# '[IB]' && !empty(custom_comment_mode) + let def = tcomment#GetCommentDef(custom_comment_mode) " TLogVAR 1, def - elseif commentMode =~? 'I' && tcomment#TypeExists(a:ft .'_inline') - let def = s:definitions[a:ft .'_inline'] - " TLogVAR 2, def - elseif customComment - let def = s:definitions[a:ft] - let commentMode = s:CommentMode(commentMode, 'G') - " TLogVAR 3, def - elseif a:0 >= 1 - let def = {'commentstring': a:1} - let commentMode = s:CommentMode(commentMode, 'G') - " TLogVAR 4, def + elseif !empty(custom_comment) + let def = tcomment#GetCommentDef(custom_comment) + let comment_mode = s:GuessCommentMode(comment_mode, supported_comment_mode) + " TLogVAR 3, def, comment_mode + elseif !empty(default) + if empty(default_cdef) + let def = {'commentstring': default} + else + let def = default_cdef + endif + let comment_mode = s:GuessCommentMode(comment_mode, default_supports_comment_mode) + " TLogVAR 4, def, comment_mode else let def = {} - let commentMode = s:CommentMode(commentMode, 'G') - " TLogVAR 5, def + let comment_mode = s:GuessCommentMode(comment_mode, '') + " TLogVAR 5, def, comment_mode endif let cdef = copy(def) - let cdef.mode = commentMode + if !has_key(cdef, 'mode') + let cdef.mode = comment_mode + endif let cdef.filetype = a:ft " TLogVAR cdef return cdef endf + function! s:GetCommentReplace(cdef, cms0) if has_key(a:cdef, 'commentstring_rx') let rs = s:BlockGetCommentString(a:cdef) else let rs = a:cms0 endif - return escape(rs, '"/') + return rs + " return escape(rs, '"/') endf + function! s:BlockGetCommentRx(cdef) if has_key(a:cdef, 'commentstring_rx') return a:cdef.commentstring_rx @@ -1341,6 +1958,7 @@ function! s:BlockGetCommentRx(cdef) endif endf + function! s:BlockGetCommentString(cdef) if has_key(a:cdef, 'middle') return a:cdef.commentstring @@ -1349,6 +1967,7 @@ function! s:BlockGetCommentString(cdef) endif endf + function! s:BlockGetMiddleString(cdef) if has_key(a:cdef, 'middle') return a:cdef.middle @@ -1358,6 +1977,25 @@ function! s:BlockGetMiddleString(cdef) endf -redraw +function! tcomment#TextObjectInlineComment() "{{{3 + let cdef = tcomment#GuessCommentType({'comment_mode': 'I'}) + let cms = escape(cdef.commentstring, '\') + let pos = getpos('.') + let lnum = pos[1] + let col = pos[2] + let cmtf = '\V'. printf(cms, '\.\{-}\%'. lnum .'l\%'. col .'c\.\{-}') + " TLogVAR cmtf, search(cmtf,'cwn') + if search(cmtf, 'cw') > 0 + let pos0 = getpos('.') + if search(cmtf, 'cwe') > 0 + let pos1 = getpos('.') + exec 'norm!' + \ pos0[1].'gg'.pos0[2].'|v'. + \ pos1[1].'gg'.pos1[2].'|'. + \ (&sel == 'exclusive' ? 'l' : '') + endif + endif +endf + " vi: ft=vim:tw=72:ts=4:fo=w2croql diff --git a/vimfiles/doc/pi_netrw.txt b/vimfiles/doc/pi_netrw.txt index 992dbde..35a61a1 100644 --- a/vimfiles/doc/pi_netrw.txt +++ b/vimfiles/doc/pi_netrw.txt @@ -1,4 +1,4 @@ -*pi_netrw.txt* For Vim version 7.3. Last change: 2013 Apr 15 +*pi_netrw.txt* For Vim version 7.4. Last change: 2014 Jan 21 ------------------------------------------------ NETRW REFERENCE MANUAL by Charles E. Campbell @@ -6,7 +6,7 @@ Author: Charles E. Campbell (remove NOSPAM from Campbell's email first) -Copyright: Copyright (C) 1999-2013 Charles E Campbell *netrw-copyright* +Copyright: Copyright (C) 1999-2014 Charles E Campbell *netrw-copyright* The VIM LICENSE applies to the files in this package, including netrw.vim, pi_netrw.txt, netrwFileHandlers.vim, netrwSettings.vim, and syntax/netrw.vim. Like anything else that's free, netrw.vim and its @@ -85,7 +85,7 @@ Copyright: Copyright (C) 1999-2013 Charles E Campbell *netrw-copyright* Marked Files: Moving................................|netrw-mm| Marked Files: Printing..............................|netrw-mp| Marked Files: Sourcing..............................|netrw-ms| - Marked Files: Setting the Target Directory..........|netrw-mt| + Marked Files: Setting the Target Directory..........|netrw-mt| Marked Files: Tagging...............................|netrw-mT| Marked Files: Target Directory Using Bookmarks......|netrw-Tb| Marked Files: Target Directory Using History........|netrw-Th| @@ -146,13 +146,13 @@ and has lines resembling > < Windows' ftp doesn't support .netrc; however, one may have in one's .vimrc: > - let g:netrw_ftp_cmd= 'c:\Windows\System32\ftp -s:C:\Users\Myself\MACHINE' + let g:netrw_ftp_cmd= 'c:\Windows\System32\ftp -s:C:\Users\MyUserName\MACHINE' < -Netrw will substitute the host's machine name for MACHINE from the url it is +Netrw will substitute the host's machine name for "MACHINE" from the url it is attempting to open, and so one may specify > userid password -for each site in a separate file in c:\Users\Myself\. +for each site in a separate file: c:\Users\MyUserName\MachineName. Now about browsing -- when you just want to look around before editing a file. For browsing on your current host, just "edit" a directory: > @@ -192,21 +192,22 @@ You may do so by placing the following two lines in your <.vimrc>: > EXTERNAL APPLICATIONS AND PROTOCOLS *netrw-externapp* {{{2 - Protocol Variable Default Value - -------- ---------------- ------------- - 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" + Protocol Variable Default Value + -------- ---------------- ------------- + 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 + http: *g:netrw_http_put_cmd* = "curl -T" + 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 overridden. By @@ -223,6 +224,9 @@ EXTERNAL APPLICATIONS AND PROTOCOLS *netrw-externapp* {{{2 let g:netrw_http_xcmd= "-dump >" < in your .vimrc. + g:netrw_http_put_cmd: this option specifies both the executable and + any needed options. This command does a PUT operation to the url. + READING *netrw-read* *netrw-nread* {{{2 @@ -321,6 +325,8 @@ CHANGING USERID AND PASSWORD *netrw-chgup* *netrw-userpass* {{{2 :call NetUserPass("uid") -- prompts for password :call NetUserPass("uid","password") -- sets global uid and password +(Related topics: |ftp| |netrw-userpass| |netrw-start|) + NETRW VARIABLES AND SETTINGS *netrw-variables* {{{2 (Also see: |netrw-browser-var| : netrw browser option variables @@ -814,8 +820,7 @@ variables listed below, and may be modified by the user. ------------------------ Option Type Setting Meaning --------- -------- -------------- --------------------------- -< - netrw_ftp variable =doesn't exist userid set by "user userid" +< netrw_ftp variable =doesn't exist userid set by "user userid" =0 userid set by "user userid" =1 userid set by "userid" NetReadFixup function =doesn't exist no change @@ -823,17 +828,18 @@ 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" 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 - g:netrw_http_cmd variable ="wget -O" else if wget is available - g:netrw_list_cmd variable ="ssh USEPORT HOSTNAME ls -Fa" - g:netrw_rcp_cmd variable ="rcp" - g:netrw_rsync_cmd variable ="rsync -a" - g:netrw_scp_cmd variable ="scp -q" - g:netrw_sftp_cmd variable ="sftp" > + g:netrw_dav_cmd var ="cadaver" if cadaver is executable + g:netrw_dav_cmd var ="curl -o" elseif curl is executable + g:netrw_fetch_cmd var ="fetch -o" if fetch is available + g:netrw_ftp_cmd var ="ftp" + g:netrw_http_cmd var ="fetch -o" if fetch is available + g:netrw_http_cmd var ="wget -O" else if wget is available + g:netrw_http_put_cmd var ="curl -T" + g:netrw_list_cmd var ="ssh USEPORT HOSTNAME ls -Fa" + g:netrw_rcp_cmd var ="rcp" + g:netrw_rsync_cmd var ="rsync -a" + g:netrw_scp_cmd var ="scp -q" + g:netrw_sftp_cmd var ="sftp" > ------------------------------------------------------------------------- < *netrw-ftp* @@ -927,6 +933,7 @@ itself: endfunction endif > +(Related topics: |ftp| |netrw-userpass| |netrw-start|) ============================================================================== 9. Browsing *netrw-browsing* *netrw-browse* *netrw-help* {{{1 @@ -1094,16 +1101,20 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 mapping defined before netrw is autoloaded, then a double clicked leftmouse button will return to the netrw browser window. See |g:netrw_retmap|. - (gvim only) like mf, will mark files + (gvim only) like mf, will mark files. Dragging + the shifted leftmouse will mark multiple files. + (see |netrw-mf|) (to disable mouse buttons while browsing: |g:netrw_mousemaps|) *netrw-quickcom* *netrw-quickcoms* QUICK REFERENCE: COMMANDS *netrw-explore-cmds* *netrw-browse-cmds* {{{2 - :NetrwClean[!] ...........................................|netrw-clean| - :NetrwSettings ...........................................|netrw-settings| + :NetrwClean[!]............................................|netrw-clean| + :NetrwSettings............................................|netrw-settings| + :Ntree....................................................|netrw-ntree| :Explore[!] [dir] Explore directory of current file......|netrw-explore| :Hexplore[!] [dir] Horizontal Split & Explore.............|netrw-explore| + :Lexplore [dir] Left Explorer Toggle...................|netrw-explore| :Nexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| :Pexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| :Rexplore Return to Explorer.....................|netrw-explore| @@ -1318,6 +1329,17 @@ See |g:netrw_dirhistmax| for how to control the quantity of history stack slots. +CHANGING TREE TOP *netrw-ntree* *:Ntree* + +One may specify a new tree top for tree listings using > + + :Ntree [dirname] + +Without a "dirname", the current line is used (and any leading depth +information is elided). +With a "dirname", the specified directory name is used. + + NETRW CLEAN *netrw-clean* *:NetrwClean* With :NetrwClean one may easily remove netrw from one's home directory; @@ -1455,7 +1477,7 @@ Associated setting variable: |g:netrw_localrmdir| |g:netrw_rm_cmd| *netrw-explore* *netrw-hexplore* *netrw-nexplore* *netrw-pexplore* -*netrw-rexplore* *netrw-sexplore* *netrw-texplore* *netrw-vexplore* +*netrw-rexplore* *netrw-sexplore* *netrw-texplore* *netrw-vexplore* *netrw-lexplore* DIRECTORY EXPLORATION COMMANDS {{{2 :[N]Explore[!] [dir]... Explore directory of current file *:Explore* @@ -1464,6 +1486,7 @@ DIRECTORY EXPLORATION COMMANDS {{{2 :[N]Sexplore[!] [dir]... Split&Explore current file's directory *:Sexplore* :Texplore [dir]... Tab & Explore *:Texplore* :[N]Vexplore[!] [dir]... Vertical Split & Explore *:Vexplore* + :Lexplore [dir]... Left Explorer Toggle *:Lexplore* Used with :Explore **/pattern : (also see |netrw-starstar|) :Nexplore............. go to next matching file *:Nexplore* @@ -1475,6 +1498,9 @@ DIRECTORY EXPLORATION COMMANDS {{{2 window will take over that window. Normally the splitting is taken horizontally. :Explore! is like :Explore, but will use vertical splitting. +:Lexplore [dir] toggles an Explorer window on the left hand side + of the current tab It will open a netrw window on the current + directory if [dir] is omitted. :Sexplore will always split the window before invoking the local-directory browser. As with Explore, the splitting is normally done horizontally. @@ -1483,7 +1509,7 @@ DIRECTORY EXPLORATION COMMANDS {{{2 :Hexplore! [dir] does an :Explore with |:aboveleft| horizontal splitting. :Vexplore [dir] does an :Explore with |:leftabove| vertical splitting. :Vexplore! [dir] does an :Explore with |:rightbelow| vertical splitting. -:Texplore [dir] does a tabnew before generating the browser window +: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. @@ -1502,6 +1528,8 @@ windows should have. of the <2-leftmouse> map (which is only available under gvim and cooperative terms). +Also see: |g:netrw_alto| |g:netrw_altv| |g:netrw_winsize| + *netrw-star* *netrw-starpat* *netrw-starstar* *netrw-starstarpat* EXPLORING WITH STARS AND PATTERNS @@ -1693,9 +1721,36 @@ As a quick shortcut, one may press > to toggle between hiding files which begin with a period (dot) and not hiding them. -Associated setting variable: |g:netrw_list_hide| |g:netrw_hide| +Associated setting variables: |g:netrw_list_hide| |g:netrw_hide| Associated topics: |netrw-a| |netrw-ctrl-h| |netrw-mh| + *netrw-gitignore* +Netrw provides a helper function 'netrw_gitignore#Hide()' that, when used with +|g:netrw_list_hide| automatically hides all git-ignored files. + +'netrw_gitignore#Hide' searches for patterns in the following files: + './.gitignore' + './.git/info/exclude' + global gitignore file: `git config --global core.excludesfile` + system gitignore file: `git config --system core.excludesfile` + +Files that do not exist, are ignored. +Git-ignore patterns are taken from existing files, and converted to patterns for +hiding files. For example, if you had '*.log' in your '.gitignore' file, it +would be converted to '.*\.log'. + +To use this function, simply assign it's output to |g:netrw_list_hide| option. + + Example: let g:netrw_list_hide= netrw_gitignore#Hide() + Git-ignored files are hidden in Netrw. + + Example: let g:netrw_list_hide= netrw_gitignore#Hide('my_gitignore_file') + Function can take additional files with git-ignore patterns. + + Example: g:netrw_list_hide= netrw_gitignore#Hide() . '.*\.swp$' + Combining 'netrw_gitignore#Hide' with custom patterns. + + IMPROVING BROWSING *netrw-listhack* *netrw-ssh-hack* {{{2 Especially with the remote directory browser, constantly entering the password @@ -1775,6 +1830,15 @@ passwords: http://sial.org/howto/openssh/publickey-auth/ + Ssh hints: + + Thomer Gil has provided a hint on how to speed up netrw+ssh: + http://thomer.com/howtos/netrw_ssh.html + + Alex Young has several hints on speeding ssh up: + http://usevim.com/2012/03/16/editing-remote-files/ + + LISTING BOOKMARKS AND HISTORY *netrw-qb* *netrw-listbookmark* {{{2 Pressing "qb" (query bookmarks) will list both the bookmarked directories and @@ -1797,8 +1861,8 @@ directory. Attempts to make a local directory that already exists (as either a file or a directory) will be detected, reported on, and ignored. Related topics: |netrw-D| -Associated setting variables: |g:netrw_localmkdir| |g:netrw_mkdir_cmd| - |g:netrw_remote_mkdir| +Associated setting variables: |g:netrw_localmkdir| |g:netrw_mkdir_cmd| + |g:netrw_remote_mkdir| |netrw-%| MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY *netrw-c* {{{2 @@ -1857,6 +1921,10 @@ like > < into $HOME/.vim/after/syntax/netrw.vim . +If the mouse is enabled and works with your vim, you may use to +mark one or more files. You may mark multiple files by dragging the shifted +leftmouse. (see |netrw-mouse|) + *markfilelist* *global_markfilelist* *local_markfilelist* All marked files are entered onto the global marked file list; there is only one such list. In addition, every netrw buffer also has its own local marked @@ -2061,7 +2129,7 @@ edit the desired file and go to the tag. Associated setting variables: |g:netrw_ctags| |g:netrw_ssh_cmd| -MARKED FILES: TARGET DIRECTORY USING BOOKMARKS |netrw-Tb| {{{2 +MARKED FILES: TARGET DIRECTORY USING BOOKMARKS *netrw-Tb* {{{2 Sets the marked file copy/move-to target (see |netrw-mc| and |netrw-mm|). @@ -2077,7 +2145,7 @@ Related topics: Marking Files by Regular Expression................|netrw-mr| -MARKED FILES: TARGET DIRECTORY USING HISTORY |netrw-Th| {{{2 +MARKED FILES: TARGET DIRECTORY USING HISTORY *netrw-Th* {{{2 Sets the marked file copy/move-to target (see |netrw-mc| and |netrw-mm|). @@ -2111,7 +2179,15 @@ your browsing preferences. (see also: |netrw-settings|) --- ----------- Var Explanation --- ----------- -< *g:netrw_alto* change from above splitting to below splitting +< *g:netrw_altfile* some like |CTRL-^| to return to the last + edited file. Choose that by setting this + parameter to 1. + Others like |CTRL-^| to return to the + netrw browsing buffer. Choose that by setting + this parameter to 0. + default: =0 + + *g:netrw_alto* change from above splitting to below splitting by setting this variable (see |netrw-o|) default: =&sb (see |'sb'|) @@ -2125,6 +2201,10 @@ your browsing preferences. (see also: |netrw-settings|) NOTE: suppressing the banner is a new feature which may cause problems. + *g:netrw_bannerbackslash* if this variable exists and is not zero, the + banner will be displayed with backslashes + rather than forward slashes. + *g:netrw_browse_split* when browsing, will open the file by: =0: re-using the same window =1: horizontally splitting the window first @@ -2135,6 +2215,10 @@ your browsing preferences. (see also: |netrw-settings|) to get vertical splitting instead of horizontal splitting. + Related topics: + |netrw-cr| |netrw-C| + |g:netrw_alto| |g:netrw_altv| + *g:netrw_browsex_viewer* specify user's preference for a viewer: > "kfmclient exec" "gnome-open" @@ -2296,24 +2380,33 @@ your browsing preferences. (see also: |netrw-settings|) stamp information and file size) = 2: wide listing (multiple files in columns) = 3: tree style listing + *g:netrw_list_hide* comma separated pattern list for hiding files Patterns are regular expressions (see |regexp|) - Example: let g:netrw_list_hide= '.*\.swp$' - default: "" + There's some special support for git-ignore + files: you may add the output from the helper + function 'netrw_gitignore#Hide() automatically + hiding all gitignored files. + For more details see |netrw-gitignore|. + + Examples: + let g:netrw_list_hide= '.*\.swp$' + let g:netrw_list_hide= netrw_gitignore#Hide().'.*\.swp$' + default: "" *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin ="copy" Windows Copies marked files (|netrw-mf|) to target directory (|netrw-mt|, |netrw-mc|) + *g:netrw_localmkdir* command for making a local directory + default: "mkdir" + *g:netrw_localmovecmd* ="mv" Linux/Unix/MacOS/Cygwin ="move" Windows Moves marked files (|netrw-mf|) to target directory (|netrw-mt|, |netrw-mm|) - *g:netrw_localmkdir* command for making a local directory - default: "mkdir" - *g:netrw_localrmdir* remove directory command (rmdir) default: "rmdir" @@ -2416,11 +2509,6 @@ your browsing preferences. (see also: |netrw-settings|) < into one's <.vimrc> to use one's own preferences. - *g:netrw_ssh_cmd* One may specify an executable command - to use instead of ssh for remote actions - such as listing, file removal, etc. - default: ssh - *g:netrw_ssh_browse_reject* ssh can sometimes produce unwanted lines, messages, banners, and whatnot that one doesn't want masquerading as "directories" and "files". @@ -2428,6 +2516,11 @@ your browsing preferences. (see also: |netrw-settings|) messages. By default its value is: '^total\s\+\d\+$' + *g:netrw_ssh_cmd* One may specify an executable command + to use instead of ssh for remote actions + such as listing, file removal, etc. + default: ssh + *g:netrw_tmpfile_escape* =' &;' escape() is applied to all temporary files @@ -2544,6 +2637,8 @@ To open a file in netrw's current directory, press "%". This map will query the user for a new filename; an empty file by that name will be placed in the netrw's current directory (ie. b:netrw_curdir). +Related topics: |netrw-d| + PREVIEW WINDOW *netrw-p* *netrw-preview* {{{2 @@ -2648,7 +2743,7 @@ One may select a netrw window for editing with the "C" mapping, or by setting g:netrw_chgwin to the selected window number. Subsequent selection of a file to edit (|netrw-cr|) will use that window. -Related topics: |netrw-cr| +Related topics: |netrw-cr| |g:netrw_browse_split| Associated setting variables: |g:netrw_chgwin| @@ -2981,15 +3076,100 @@ which is loaded automatically at startup (assuming :set nocp). read/write your file over the network in a separate tab. To save the file, use > + :tabnext :set bt= :w! DBG -< Please send that information to 's maintainer, > + +< Furthermore, it'd be helpful if you would type > + :Dsep +< after each command you issue, thereby making it easier to + associate which part of the debugging trace is due to which + command. + + Please send that information to 's maintainer, > NdrOchip at ScampbellPfamily.AbizM - NOSPAM < ============================================================================== 12. History *netrw-history* {{{1 + v151: Jan 22, 2014 * extended :Rexplore to return to buffer + prior to Explore or editing a directory + * (Ken Takata) netrw gave error when + clipboard was disabled. Sol'n: Placed + several if has("clipboard") tests in. + v150: Jul 12, 2013 * removed a "keepalt" to allow ":e #" to + return to the netrw directory listing + Jul 13, 2013 * (Jonas Diemer) suggested changing + a to . + Jul 21, 2013 * (Yuri Kanivetsky) reported that netrw's + use of mkdir did not produce directories + following umask. + Aug 27, 2013 * introduced |g:netrw_altfile| option + Sep 05, 2013 * s:Strlen() now uses |strdisplaywidth()| + when available, by default + Sep 12, 2013 * (Selyano Baldo) reported that netrw wasn't + opening some directories properly from the + command line. + Nov 09, 2013 * |:Lexplore| introduced + * (Ondrej Platek) reported an issue with + netrw's trees (P15). Fixed. + * (Jorge Solis) reported that "t" in + tree mode caused netrw to forget its + line position. + Dec 05, 2013 * Added file marking + (see |netrw-mf|) + Dec 05, 2013 * (Yasuhiro Matsumoto) Explore should use + strlen() instead s:Strlen() when handling + multibyte chars with strpart() + (ie. strpart() is byte oriented, not + display-width oriented). + Dec 09, 2013 * (Ken Takata) Provided a patch; File sizes + and a portion of timestamps were wrongly + highlighted with the directory color when + setting `:let g:netrw_liststyle=1` on Windows. + * (Paul Domaskis) noted that sometimes + cursorline was activating in non-netrw + windows. All but one setting of cursorline + was done via setl; there was one that was + overlooked. Fixed. + Dec 24, 2013 * (esquifit) asked that netrw allow the + /cygdrive prefix be a user-alterable + parameter. + Jan 02, 2014 * Fixed a problem with netrw-based ballon + evaluation (ie. netrw#NetrwBaloonHelp() + not having been loaded error messages) + Jan 03, 2014 * Fixed a problem with tree listings + * New command installed: |:Ntree| + Jan 06, 2014 * (Ivan Brennan) reported a problem with + |netrw-P|. Fixed. + Jan 06, 2014 * Fixed a problem with |netrw-P| when the + modified file was to be abandoned. + Jan 15, 2014 * (Matteo Cavalleri) reported that when the + banner is suppressed and tree listing is + used, a blank line was left at the top of + the display. Fixed. + Jan 20, 2014 * (Gideon Go) reported that, in tree listing + style, with a previous window open, that + the wrong directory was being used to open + a file. Fixed. (P21) + v149: Apr 18, 2013 * in wide listing format, now have maps for + w and b to move to next/previous file + Apr 26, 2013 * one may now copy files in the same + directory; netrw will issue requests for + what names the files should be copied under + Apr 29, 2013 * Trying Benzinger's problem again. Seems + that commenting out the BufEnter and + installing VimEnter (only) works. Weird + problem! (tree listing, vim -O Dir1 Dir2) + May 01, 2013 * :Explore ftp://... wasn't working. Fixed. + May 02, 2013 * introduced |g:netrw_bannerbackslash| as + requested by Paul Domaskis. + Jul 03, 2013 * Explore now avoids splitting when a buffer + will be hidden. + v148: Apr 16, 2013 * changed Netrw's Style menu to allow direct + choice of listing style, hiding style, and + sorting style v147: Nov 24, 2012 * (James McCoy) Even with g:netrw_dirhistmax at zero, the .vim/ directory would be created to support history/bookmarks. I've diff --git a/vimfiles/doc/tags b/vimfiles/doc/tags index 087c1d8..9710d06 100644 --- a/vimfiles/doc/tags +++ b/vimfiles/doc/tags @@ -31,6 +31,7 @@ :IX visincr.txt /*:IX* :LP LogiPat.txt /*:LP* :LPF LogiPat.txt /*:LPF* +:Lexplore pi_netrw.txt /*:Lexplore* :Linediff linediff.txt /*:Linediff* :LinediffReset linediff.txt /*:LinediffReset* :LogiPat LogiPat.txt /*:LogiPat* @@ -42,6 +43,7 @@ :Nread pi_netrw.txt /*:Nread* :Ns pi_netrw.txt /*:Ns* :Nsource pi_netrw.txt /*:Nsource* +:Ntree pi_netrw.txt /*:Ntree* :Nw pi_netrw.txt /*:Nw* :Nwrite pi_netrw.txt /*:Nwrite* :Pexplore pi_netrw.txt /*:Pexplore* @@ -82,6 +84,26 @@ :VCSVimDiff vcscommand.txt /*:VCSVimDiff* :Vexplore pi_netrw.txt /*:Vexplore* :VimballList pi_vimball.txt /*:VimballList* +TComment-_ tcomment.txt /*TComment-_* +TComment-__ tcomment.txt /*TComment-__* +TComment-_a tcomment.txt /*TComment-_a* +TComment-_b tcomment.txt /*TComment-_b* +TComment-_n tcomment.txt /*TComment-_n* +TComment-_p tcomment.txt /*TComment-_p* +TComment-_r tcomment.txt /*TComment-_r* +TComment-_s tcomment.txt /*TComment-_s* +TComment- tcomment.txt /*TComment-* +TComment- tcomment.txt /*TComment-* +TComment-a tcomment.txt /*TComment-a* +TComment-b tcomment.txt /*TComment-b* +TComment-ca tcomment.txt /*TComment-ca* +TComment-cc tcomment.txt /*TComment-cc* +TComment-i tcomment.txt /*TComment-i* +TComment-n tcomment.txt /*TComment-n* +TComment-p tcomment.txt /*TComment-p* +TComment-r tcomment.txt /*TComment-r* +TComment-s tcomment.txt /*TComment-s* +TComment-ic tcomment.txt /*TComment-ic* Align-copyright Align.txt /*Align-copyright* C-Reference crefvim.txt /*C-Reference* GetLatestVimScripts pi_getscript.txt /*GetLatestVimScripts* @@ -249,6 +271,7 @@ b:match_wholeBR matchit.txt /*b:match_wholeBR* b:match_word matchit.txt /*b:match_word* b:match_words matchit.txt /*b:match_words* b:netrw_lastfile pi_netrw.txt /*b:netrw_lastfile* +b:tcomment_def_{NAME} tcomment.txt /*b:tcomment_def_{NAME}* cecutil cecutil.txt /*cecutil* cecutil-cmd cecutil.txt /*cecutil-cmd* cecutil-contents cecutil.txt /*cecutil-contents* @@ -1515,9 +1538,11 @@ g:Netrw_corehandler pi_netrw.txt /*g:Netrw_corehandler* g:Netrw_funcref pi_netrw.txt /*g:Netrw_funcref* g:alignmaps_euronumber Align.txt /*g:alignmaps_euronumber* g:alignmaps_usanumber Align.txt /*g:alignmaps_usanumber* +g:netrw_altfile pi_netrw.txt /*g:netrw_altfile* g:netrw_alto pi_netrw.txt /*g:netrw_alto* g:netrw_altv pi_netrw.txt /*g:netrw_altv* g:netrw_banner pi_netrw.txt /*g:netrw_banner* +g:netrw_bannerbackslash pi_netrw.txt /*g:netrw_bannerbackslash* g:netrw_browse_split pi_netrw.txt /*g:netrw_browse_split* g:netrw_browsex_viewer pi_netrw.txt /*g:netrw_browsex_viewer* g:netrw_bufsettings pi_netrw.txt /*g:netrw_bufsettings* @@ -1548,6 +1573,7 @@ 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_put_cmd pi_netrw.txt /*g:netrw_http_put_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* @@ -1594,14 +1620,19 @@ g:netrw_use_nt_rcp pi_netrw.txt /*g:netrw_use_nt_rcp* g:netrw_win95ftp pi_netrw.txt /*g:netrw_win95ftp* g:netrw_winsize pi_netrw.txt /*g:netrw_winsize* g:netrw_xstrlen pi_netrw.txt /*g:netrw_xstrlen* +g:tcomment#blank_lines tcomment.txt /*g:tcomment#blank_lines* g:tcomment#ignore_char_type tcomment.txt /*g:tcomment#ignore_char_type* +g:tcomment#ignore_comment_def tcomment.txt /*g:tcomment#ignore_comment_def* +g:tcomment#options_comments tcomment.txt /*g:tcomment#options_comments* +g:tcomment#options_commentstring tcomment.txt /*g:tcomment#options_commentstring* g:tcomment#replacements_c tcomment.txt /*g:tcomment#replacements_c* +g:tcomment#replacements_xml tcomment.txt /*g:tcomment#replacements_xml* +g:tcomment#rstrip_on_uncomment tcomment.txt /*g:tcomment#rstrip_on_uncomment* g:tcomment#syntax_substitute tcomment.txt /*g:tcomment#syntax_substitute* -g:tcommentBlankLines tcomment.txt /*g:tcommentBlankLines* -g:tcommentBlockC tcomment.txt /*g:tcommentBlockC* g:tcommentBlockC2 tcomment.txt /*g:tcommentBlockC2* g:tcommentBlockXML tcomment.txt /*g:tcommentBlockXML* g:tcommentGuessFileType tcomment.txt /*g:tcommentGuessFileType* +g:tcommentGuessFileType_blade tcomment.txt /*g:tcommentGuessFileType_blade* g:tcommentGuessFileType_django tcomment.txt /*g:tcommentGuessFileType_django* g:tcommentGuessFileType_dsl tcomment.txt /*g:tcommentGuessFileType_dsl* g:tcommentGuessFileType_eruby tcomment.txt /*g:tcommentGuessFileType_eruby* @@ -1617,10 +1648,12 @@ g:tcommentMapLeader1 tcomment.txt /*g:tcommentMapLeader1* g:tcommentMapLeader2 tcomment.txt /*g:tcommentMapLeader2* g:tcommentMapLeaderOp1 tcomment.txt /*g:tcommentMapLeaderOp1* g:tcommentMapLeaderOp2 tcomment.txt /*g:tcommentMapLeaderOp2* +g:tcommentMaps tcomment.txt /*g:tcommentMaps* g:tcommentModeExtra tcomment.txt /*g:tcommentModeExtra* g:tcommentOpModeExtra tcomment.txt /*g:tcommentOpModeExtra* g:tcommentOptions tcomment.txt /*g:tcommentOptions* g:tcommentSyntaxMap tcomment.txt /*g:tcommentSyntaxMap* +g:tcommentTextObjectInlineComment tcomment.txt /*g:tcommentTextObjectInlineComment* g:tcomment_types tcomment.txt /*g:tcomment_types* g:vimball_home pi_vimball.txt /*g:vimball_home* g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir* @@ -1662,6 +1695,15 @@ gundo_right gundo.txt /*gundo_right* gundo_tree_statusline gundo.txt /*gundo_tree_statusline* gundo_width gundo.txt /*gundo_width* http pi_netrw.txt /*http* +i_TComment- tcomment.txt /*i_TComment-* +i_TComment- tcomment.txt /*i_TComment-* +i_TComment-a tcomment.txt /*i_TComment-a* +i_TComment-b tcomment.txt /*i_TComment-b* +i_TComment-i tcomment.txt /*i_TComment-i* +i_TComment-n tcomment.txt /*i_TComment-n* +i_TComment-p tcomment.txt /*i_TComment-p* +i_TComment-r tcomment.txt /*i_TComment-r* +i_TComment-s tcomment.txt /*i_TComment-s* linediff linediff.txt /*linediff* linediff-commands linediff.txt /*linediff-commands* linediff-contents linediff.txt /*linediff-contents* @@ -1709,6 +1751,12 @@ matchit-troubleshoot matchit.txt /*matchit-troubleshoot* matchit-v_% matchit.txt /*matchit-v_%* matchit.txt matchit.txt /*matchit.txt* matchit.vim matchit.txt /*matchit.vim* +n_TComment-gC tcomment.txt /*n_TComment-gC* +n_TComment-gCb tcomment.txt /*n_TComment-gCb* +n_TComment-gCc tcomment.txt /*n_TComment-gCc* +n_TComment-gc tcomment.txt /*n_TComment-gc* +n_TComment-gcb tcomment.txt /*n_TComment-gcb* +n_TComment-gcc tcomment.txt /*n_TComment-gcc* netreadfixup pi_netrw.txt /*netreadfixup* netrw pi_netrw.txt /*netrw* netrw-% pi_netrw.txt /*netrw-%* @@ -1719,6 +1767,8 @@ netrw-O pi_netrw.txt /*netrw-O* netrw-P pi_netrw.txt /*netrw-P* netrw-R pi_netrw.txt /*netrw-R* netrw-S pi_netrw.txt /*netrw-S* +netrw-Tb pi_netrw.txt /*netrw-Tb* +netrw-Th pi_netrw.txt /*netrw-Th* netrw-U pi_netrw.txt /*netrw-U* netrw-X pi_netrw.txt /*netrw-X* netrw-a pi_netrw.txt /*netrw-a* @@ -1768,6 +1818,7 @@ netrw-gd pi_netrw.txt /*netrw-gd* netrw-getftype pi_netrw.txt /*netrw-getftype* netrw-gf pi_netrw.txt /*netrw-gf* netrw-gh pi_netrw.txt /*netrw-gh* +netrw-gitignore pi_netrw.txt /*netrw-gitignore* netrw-gp pi_netrw.txt /*netrw-gp* netrw-gx pi_netrw.txt /*netrw-gx* netrw-handler pi_netrw.txt /*netrw-handler* @@ -1782,6 +1833,7 @@ netrw-incompatible pi_netrw.txt /*netrw-incompatible* netrw-internal-variables pi_netrw.txt /*netrw-internal-variables* netrw-intro-browse pi_netrw.txt /*netrw-intro-browse* netrw-leftmouse pi_netrw.txt /*netrw-leftmouse* +netrw-lexplore pi_netrw.txt /*netrw-lexplore* netrw-list pi_netrw.txt /*netrw-list* netrw-listbookmark pi_netrw.txt /*netrw-listbookmark* netrw-listhack pi_netrw.txt /*netrw-listhack* @@ -1812,6 +1864,7 @@ netrw-netrc pi_netrw.txt /*netrw-netrc* netrw-nexplore pi_netrw.txt /*netrw-nexplore* netrw-noload pi_netrw.txt /*netrw-noload* netrw-nread pi_netrw.txt /*netrw-nread* +netrw-ntree pi_netrw.txt /*netrw-ntree* netrw-nwrite pi_netrw.txt /*netrw-nwrite* netrw-o pi_netrw.txt /*netrw-o* netrw-options pi_netrw.txt /*netrw-options* @@ -1914,15 +1967,20 @@ srchrplchigrp-examples SrchRplcHiGrp.txt /*srchrplchigrp-examples* tcomment#Comment() tcomment.txt /*tcomment#Comment()* tcomment#CommentAs() tcomment.txt /*tcomment#CommentAs()* tcomment#DefineType() tcomment.txt /*tcomment#DefineType()* +tcomment#GetCommentDef() tcomment.txt /*tcomment#GetCommentDef()* tcomment#GuessCommentType() tcomment.txt /*tcomment#GuessCommentType()* tcomment#Operator() tcomment.txt /*tcomment#Operator()* tcomment#OperatorAnyway() tcomment.txt /*tcomment#OperatorAnyway()* tcomment#OperatorLine() tcomment.txt /*tcomment#OperatorLine()* tcomment#OperatorLineAnyway() tcomment.txt /*tcomment#OperatorLineAnyway()* tcomment#SetOption() tcomment.txt /*tcomment#SetOption()* +tcomment#TextObjectInlineComment() tcomment.txt /*tcomment#TextObjectInlineComment()* tcomment-maps tcomment.txt /*tcomment-maps* tcomment-operator tcomment.txt /*tcomment-operator* tcomment.txt tcomment.txt /*tcomment.txt* +v_TComment- tcomment.txt /*v_TComment-* +v_TComment-i tcomment.txt /*v_TComment-i* +v_TComment-ic tcomment.txt /*v_TComment-ic* v_[% matchit.txt /*v_[%* v_]% matchit.txt /*v_]%* v_a% matchit.txt /*v_a%* @@ -2001,6 +2059,10 @@ visincr-raggedright visincr.txt /*visincr-raggedright* visincr-restrict visincr.txt /*visincr-restrict* visincr-usage visincr.txt /*visincr-usage* visincr.txt visincr.txt /*visincr.txt* +x_TComment-__ tcomment.txt /*x_TComment-__* +x_TComment-_i tcomment.txt /*x_TComment-_i* +x_TComment-gC tcomment.txt /*x_TComment-gC* +x_TComment-gc tcomment.txt /*x_TComment-gc* xml-plugin-callbacks xml-plugin.txt /*xml-plugin-callbacks* xml-plugin-html xml-plugin.txt /*xml-plugin-html* xml-plugin-mappings xml-plugin.txt /*xml-plugin-mappings* diff --git a/vimfiles/doc/tcomment.txt b/vimfiles/doc/tcomment.txt index 1bf81c9..f2dea38 100644 --- a/vimfiles/doc/tcomment.txt +++ b/vimfiles/doc/tcomment.txt @@ -63,23 +63,33 @@ Primary key maps for normal and insert mode: :: :TComment :: :TComment b :: :TCommentBlock + In insert mode, the cursor will be positioned inside + the comment. In normal mode, the cursor will stay + put. a :: :TCommentAs n :: :TCommentAs &filetype s :: :TCommentAs &filetype_ i :: :TCommentInline (in normal and insert mode, this map will create an empty inline comment, which isn't suitable for all filetypes though) + In insert mode, the cursor will be positioned inside + the comment. In normal mode, the cursor will stay + put. r :: :TCommentRight p :: Comment the current inner paragraph - :: :TComment with count argument (a number from 1 to 9) - (see |tcomment#Comment()|) + :: Set the count argument (a number from 1 to 9) for use with + the subsequent tcomment map/command (see + |tcomment#Comment()|) + E.g. in JavaScript, in order to get an empty /** */ + comment for documentation purposes, in insert mode type + 2i + In order to get an empty block comment like > + /** + * + */ +< type 2b -Primary key maps for visual mode: - - :: :TComment - i :: :TCommentInline - :: :TComment with count argument (a number from 1 to 9) - (see |tcomment#Comment()|) +Most of the above maps are also available in visual mode. A secondary set of key maps is defined for normal and insert mode: @@ -114,24 +124,72 @@ please make sure, you have the current version of vimball (vimscript ======================================================================== Contents~ + g:tcommentMaps ...................... |g:tcommentMaps| g:tcommentMapLeader1 ................ |g:tcommentMapLeader1| g:tcommentMapLeader2 ................ |g:tcommentMapLeader2| g:tcommentMapLeaderOp1 .............. |g:tcommentMapLeaderOp1| g:tcommentMapLeaderOp2 .............. |g:tcommentMapLeaderOp2| + g:tcommentTextObjectInlineComment ... |g:tcommentTextObjectInlineComment| :TComment ........................... |:TComment| :TCommentAs ......................... |:TCommentAs| :TCommentRight ...................... |:TCommentRight| :TCommentBlock ...................... |:TCommentBlock| :TCommentInline ..................... |:TCommentInline| :TCommentMaybeInline ................ |:TCommentMaybeInline| - g:tcommentBlankLines ................ |g:tcommentBlankLines| + TComment- ........... |TComment-| + v_TComment- ......... |v_TComment-| + i_TComment- ......... |i_TComment-| + TComment-p ............... |TComment-p| + i_TComment-p ............. |i_TComment-p| + TComment- ......... |TComment-| + i_TComment- ....... |i_TComment-| + i_TComment-r ............. |i_TComment-r| + TComment-r ............... |TComment-r| + v_TComment-i ............. |v_TComment-i| + TComment-i ............... |TComment-i| + i_TComment-i ............. |i_TComment-i| + TComment-b ............... |TComment-b| + i_TComment-b ............. |i_TComment-b| + TComment-a ............... |TComment-a| + i_TComment-a ............. |i_TComment-a| + TComment-n ............... |TComment-n| + i_TComment-n ............. |i_TComment-n| + TComment-s ............... |TComment-s| + i_TComment-s ............. |i_TComment-s| + TComment-cc .............. |TComment-cc| + TComment-ca .............. |TComment-ca| + TComment-__ ........... |TComment-__| + x_TComment-__ ......... |x_TComment-__| + TComment-_p ........... |TComment-_p| + TComment-_ ..... |TComment-_| + x_TComment-_i ......... |x_TComment-_i| + TComment-_r ........... |TComment-_r| + TComment-_b ........... |TComment-_b| + TComment-_a ........... |TComment-_a| + TComment-_n ........... |TComment-_n| + TComment-_s ........... |TComment-_s| + n_TComment-gC ................. |n_TComment-gC| + n_TComment-gCc ................ |n_TComment-gCc| + n_TComment-gCb ................ |n_TComment-gCb| + x_TComment-gC ................. |x_TComment-gC| + v_TComment-ic ................. |v_TComment-ic| + TComment-ic ................... |TComment-ic| + n_TComment-gcc ................ |n_TComment-gcc| + n_TComment-gcb ................ |n_TComment-gcb| + x_TComment-gc ................. |x_TComment-gc| + n_TComment-gc ................. |n_TComment-gc| + g:tcomment#blank_lines .............. |g:tcomment#blank_lines| + g:tcomment#rstrip_on_uncomment ...... |g:tcomment#rstrip_on_uncomment| g:tcommentModeExtra ................. |g:tcommentModeExtra| g:tcommentOpModeExtra ............... |g:tcommentOpModeExtra| g:tcommentOptions ................... |g:tcommentOptions| + g:tcomment#options_comments ......... |g:tcomment#options_comments| + g:tcomment#options_commentstring .... |g:tcomment#options_commentstring| g:tcomment#ignore_char_type ......... |g:tcomment#ignore_char_type| g:tcommentGuessFileType ............. |g:tcommentGuessFileType| g:tcommentGuessFileType_dsl ......... |g:tcommentGuessFileType_dsl| g:tcommentGuessFileType_php ......... |g:tcommentGuessFileType_php| + g:tcommentGuessFileType_blade ....... |g:tcommentGuessFileType_blade| g:tcommentGuessFileType_html ........ |g:tcommentGuessFileType_html| g:tcommentGuessFileType_tskeleton ... |g:tcommentGuessFileType_tskeleton| g:tcommentGuessFileType_vim ......... |g:tcommentGuessFileType_vim| @@ -142,12 +200,14 @@ Contents~ g:tcomment#syntax_substitute ........ |g:tcomment#syntax_substitute| g:tcommentSyntaxMap ................. |g:tcommentSyntaxMap| g:tcomment#replacements_c ........... |g:tcomment#replacements_c| - g:tcommentBlockC .................... |g:tcommentBlockC| - g:tcommentBlockC2 ................... |g:tcommentBlockC2| g:tcommentInlineC ................... |g:tcommentInlineC| + g:tcommentBlockC2 ................... |g:tcommentBlockC2| + g:tcomment#replacements_xml ......... |g:tcomment#replacements_xml| g:tcommentBlockXML .................. |g:tcommentBlockXML| g:tcommentInlineXML ................. |g:tcommentInlineXML| + g:tcomment#ignore_comment_def ....... |g:tcomment#ignore_comment_def| tcomment#DefineType ................. |tcomment#DefineType()| + tcomment#GetCommentDef .............. |tcomment#GetCommentDef()| g:tcomment_types .................... |g:tcomment_types| tcomment#Comment .................... |tcomment#Comment()| tcomment#SetOption .................. |tcomment#SetOption()| @@ -157,11 +217,16 @@ Contents~ tcomment#OperatorLineAnyway ......... |tcomment#OperatorLineAnyway()| tcomment#CommentAs .................. |tcomment#CommentAs()| tcomment#GuessCommentType ........... |tcomment#GuessCommentType()| + tcomment#TextObjectInlineComment .... |tcomment#TextObjectInlineComment()| ======================================================================== plugin/tcomment.vim~ + *g:tcommentMaps* +g:tcommentMaps (default: 1) + If true, set maps. + *g:tcommentMapLeader1* g:tcommentMapLeader1 (default: '') g:tcommentMapLeader1 should be a shortcut that can be used with @@ -180,6 +245,9 @@ g:tcommentMapLeaderOp1 (default: 'gc') g:tcommentMapLeaderOp2 (default: 'gC') See |tcomment-operator|. + *g:tcommentTextObjectInlineComment* +g:tcommentTextObjectInlineComment (default: 'ic') + *:TComment* :[range]TComment[!] ?ARGS... If there is a visual selection that begins and ends in the same line, @@ -238,13 +306,146 @@ g:tcommentMapLeaderOp2 (default: 'gC') 1. a list of key=value pairs 2. 1-2 values for: ?commentBegin, ?commentEnd + *TComment-* +TComment- ... :TComment + + *v_TComment-* +v_TComment- ... :TCommentMaybeInline + + *i_TComment-* +i_TComment- ... :TComment + + *TComment-p* +TComment-p ... m`vip:TComment`` + + *i_TComment-p* +i_TComment-p ... :norm! m`vip:TComment`` + + *TComment-* +TComment- ... :TComment + + *i_TComment-* +i_TComment- ... :TComment + + *i_TComment-r* +i_TComment-r ... :TCommentRight + + *TComment-r* +TComment-r ... :TCommentRight + + *v_TComment-i* +v_TComment-i ... :TCommentInline + + *TComment-i* +TComment-i ... v:TCommentInline mode=I# + + *i_TComment-i* +i_TComment-i ... v:TCommentInline mode=# + + *TComment-b* +TComment-b ... :TCommentBlock + + *i_TComment-b* +i_TComment-b ... :TCommentBlock mode=# + + *TComment-a* +TComment-a ... :TCommentAs + + *i_TComment-a* +i_TComment-a ... :TCommentAs + + *TComment-n* +TComment-n ... :TCommentAs =&ft + + *i_TComment-n* +i_TComment-n ... :TCommentAs =&ft + + *TComment-s* +TComment-s ... :TCommentAs =&ft_ + + *i_TComment-s* +i_TComment-s ... :TCommentAs =&ft_ + + *TComment-cc* +TComment-cc ... :call tcomment#SetOption("count", v:count1) + + *TComment-ca* +TComment-ca ... :call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete")) + + *TComment-__* +TComment-__ ... :TComment + + *x_TComment-__* +x_TComment-__ ... :TCommentMaybeInline + + *TComment-_p* +TComment-_p ... vip:TComment + + *TComment-_* +TComment-_ ... :TComment + + *x_TComment-_i* +x_TComment-_i ... :TCommentInline + + *TComment-_r* +TComment-_r ... :TCommentRight + + *TComment-_b* +TComment-_b ... :TCommentBlock + + *TComment-_a* +TComment-_a ... :TCommentAs + + *TComment-_n* +TComment-_n ... :TCommentAs =&ft + + *TComment-_s* +TComment-_s ... :TCommentAs =&ft_ + + *n_TComment-gC* +n_TComment-gC ... :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnywayg@ + + *n_TComment-gCc* +n_TComment-gCc ... :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnywayg@$ + + *n_TComment-gCb* +n_TComment-gCb ... :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLineg@ + + *x_TComment-gC* +x_TComment-gC ... :TCommentMaybeInline! + + *v_TComment-ic* +v_TComment-ic ... :call tcomment#TextObjectInlineComment() + + *TComment-ic* +TComment-ic ... :call tcomment#TextObjectInlineComment() + + *n_TComment-gcc* +n_TComment-gcc ... :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineg@$ + + *n_TComment-gcb* +n_TComment-gcb ... :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLineg@ + + *x_TComment-gc* +x_TComment-gc ... :TCommentMaybeInline + + *n_TComment-gc* +n_TComment-gc ... :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operatorg@ + ======================================================================== autoload/tcomment.vim~ - *g:tcommentBlankLines* -g:tcommentBlankLines (default: 1) - If true, comment blank lines too + *g:tcomment#blank_lines* +g:tcomment#blank_lines (default: 2) + If 1, comment blank lines too. + If 2, also comment blank lines within indented code blocks + (requires mixedindent -- see |tcomment#Comment()|). + + *g:tcomment#rstrip_on_uncomment* +g:tcomment#rstrip_on_uncomment (default: 1) + If 1, remove right-hand whitespace on uncomment from empty lines. + If 2, remove right-hand whitespace on uncomment from all lines. *g:tcommentModeExtra* g:tcommentModeExtra (default: '') @@ -271,6 +472,14 @@ g:tcommentOptions (default: {}) let g:tcommentOptions = {'col': 1} < + *g:tcomment#options_comments* +g:tcomment#options_comments (default: {'whitespace': 'both'}) + Options when using a the 'comments' option. + + *g:tcomment#options_commentstring* +g:tcomment#options_commentstring (default: {'whitespace': 'both'}) + Options when using a the 'commentstring' option. + *g:tcomment#ignore_char_type* g:tcomment#ignore_char_type (default: 1) |text-objects| for use with |tcomment#Operator| can have different @@ -303,6 +512,10 @@ g:tcommentGuessFileType_php (default: 'html') thus assume that the buffers default comment style isn't php but html. + *g:tcommentGuessFileType_blade* +g:tcommentGuessFileType_blade (default: 'html') + See |g:tcommentGuessFileType_php|. + *g:tcommentGuessFileType_html* g:tcommentGuessFileType_html (default: 1) @@ -341,28 +554,36 @@ g:tcommentSyntaxMap (default: {...}) g:tcomment#replacements_c (default: {...}) Replacements for c filetype. - *g:tcommentBlockC* -g:tcommentBlockC (default: {...}) - Generic c-like block comments. + *g:tcommentInlineC* +g:tcommentInlineC (default: {...}) + Generic c-like comments. *g:tcommentBlockC2* g:tcommentBlockC2 (default: {...}) Generic c-like block comments (alternative markup). - *g:tcommentInlineC* -g:tcommentInlineC (default: g:tcommentLineC) - Generic c-like comments. + *g:tcomment#replacements_xml* +g:tcomment#replacements_xml (default: {...}) + Replacements for xml filetype. *g:tcommentBlockXML* -g:tcommentBlockXML (default: "\n ") +g:tcommentBlockXML (default: {...}) Generic xml-like block comments. *g:tcommentInlineXML* -g:tcommentInlineXML (default: "") +g:tcommentInlineXML (default: {...}) Generic xml-like comments. + *g:tcomment#ignore_comment_def* +g:tcomment#ignore_comment_def (default: []) + A list of names or filetypes, which should be ignored by + |tcomment#DefineType()| -- no custom comment definition will be + stored for these names. + + This variable should be set before loading autoload/tcomment.vim. + *tcomment#DefineType()* -tcomment#DefineType(name, commentdef) +tcomment#DefineType(name, commentdef, ?cdef={}, ?anyway=0) If you don't explicitly define a comment style, |:TComment| will use 'commentstring' instead. We override the default values here in order to have a blank after the comment marker. Block comments work only if @@ -391,6 +612,13 @@ tcomment#DefineType(name, commentdef) args is a list of key=value pairs) to find out which fields can be used. + *tcomment#GetCommentDef()* +tcomment#GetCommentDef(name, ...) + Return the comment definition for NAME. + *b:tcomment_def_{NAME}* + Return b:tcomment_def_{NAME} if the variable exists. Otherwise return + the comment definition as set with |tcomment#DefineType|. + *g:tcomment_types* g:tcomment_types (default: {}) A dictionary of NAME => COMMENT DEFINITION (see |tcomment#DefineType|) @@ -401,7 +629,7 @@ g:tcomment_types (default: {}) *tcomment#Comment()* tcomment#Comment(beg, end, ...) - tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...) + tcomment#Comment(line1, line2, ?comment_mode, ?comment_anyway, ?args...) args... are either: 1. a list of key=value pairs where known keys are (see also |g:tcommentOptions|): @@ -409,7 +637,8 @@ tcomment#Comment(beg, end, ...) count=N ... Repeat the comment string N times col=N ... Start the comment at column N (in block mode; must be smaller than |indent()|) - mode=STRING ... See the notes below on the "commentMode" argument + mode=STRING ... See the notes below on the "comment_mode" argument + mode_extra=STRING ... Add to comment_mode begin=STRING ... Comment prefix end=STRING ... Comment postfix middle=STRING ... Middle line comments in block mode @@ -417,17 +646,29 @@ tcomment#Comment(beg, end, ...) that should be multiplied by "count" rxend=N ... The above for "end" rxmid=N ... The above for "middle" + mixedindent=BOOL ... If true, allow use of mixed + characters for indentation commentstring_rx ... A regexp format string that matches commented lines (no new groups may be introduced, the |regexp| is |\V|; % have to be doubled); "commentstring", "begin" and optionally "end" must be defined or deducible. + whitespace ... Define whether commented text is + surrounded with whitespace; if + both ... surround with whitespace (default) + left ... keep whitespace on the left + right... keep whitespace on the right + no ... don't use whitespace + strip_whitespace ... Strip trailing whitespace: if 1 + (default), strip from empty lines only, + if 2, always strip whitespace; if 0, + don't strip any whitespace 2. 1-2 values for: ?commentPrefix, ?commentPostfix 3. a dictionary (internal use only) - commentMode: - G ... guess the value of commentMode + comment_mode (see also ¦g:tcommentModeExtra¦): + G ... guess the value of comment_mode B ... block (use extra lines for the comment markers) i ... maybe inline, guess I ... inline @@ -453,7 +694,7 @@ tcomment#OperatorAnyway(type) tcomment#OperatorLineAnyway(type) *tcomment#CommentAs()* -tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...) +tcomment#CommentAs(beg, end, comment_anyway, filetype, ?args...) Where args is either: 1. A count NUMBER 2. An args list (see the notes on the "args" argument of @@ -469,7 +710,7 @@ tcomment#GuessFileType(?options={}) beg ................ (default = line(".")) end ................ (default = line(".")) - commentMode ........ (default = "G") + comment_mode ........ (default = "G") filetype ........... (default = &filetype) fallbackFiletype ... (default = "") @@ -478,6 +719,9 @@ tcomment#GuessFileType(?options={}) between lines "beg" and "end" is in the "filetype" key of the return value. It returns the first discernible filetype it encounters. + *tcomment#TextObjectInlineComment()* +tcomment#TextObjectInlineComment() + vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/vimfiles/plugin/netrwPlugin.vim b/vimfiles/plugin/netrwPlugin.vim index deabd81..d7439f8 100644 --- a/vimfiles/plugin/netrwPlugin.vim +++ b/vimfiles/plugin/netrwPlugin.vim @@ -1,9 +1,9 @@ " netrwPlugin.vim: Handles file transfer and remote directory listing across a network " PLUGIN SECTION -" Date: Dec 06, 2012 +" Date: Dec 31, 2013 " Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim -" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 +" Copyright: Copyright (C) 1999-2013 Charles E. Campbell {{{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,38 +20,44 @@ if &cp || exists("g:loaded_netrwPlugin") finish endif -let g:loaded_netrwPlugin = "v147" +let g:loaded_netrwPlugin = "v150" if v:version < 702 - echohl WarningMsg | echo "***netrw*** you need vim version 7.2 for this version of netrw" | echohl None + echohl WarningMsg + echo "***warning*** you need vim version 7.2 for this version of netrw" + echohl None + finish +endif +if v:version < 703 || (v:version == 703 && !has("patch465")) + echohl WarningMsg + echo "***warning*** this version of netrw needs vim 7.3.465 or later" + echohl Normal finish endif let s:keepcpo = &cpo set cpo&vim +"DechoRemOn " --------------------------------------------------------------------- " Public Interface: {{{1 -" Local Browsing: {{{2 +" Local Browsing Autocmds: {{{2 augroup FileExplorer au! -" au BufReadCmd *[/\\] sil! call s:LocalBrowse(expand("")) -" au BufEnter *[^/\\] sil! call s:LocalBrowse(expand("")) -" au VimEnter *[^/\\] sil! call s:VimEnter(expand("")) - au BufEnter * sil! call s:LocalBrowse(expand("")) - au VimEnter * sil! call s:VimEnter(expand("")) + au BufEnter * sil call s:LocalBrowse(expand("")) + au VimEnter * sil call s:VimEnter(expand("")) if has("win32") || has("win95") || has("win64") || has("win16") - au BufEnter .* sil! call s:LocalBrowse(expand("")) + au BufEnter .* sil call s:LocalBrowse(expand("")) endif augroup END " Network Browsing Reading Writing: {{{2 augroup Network au! - au BufReadCmd file://* call netrw#FileUrlRead(expand("")) + au BufReadCmd file://* call netrw#FileUrlRead(expand("")) au BufReadCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufReadPre ".fnameescape(expand(""))|call netrw#Nread(2,expand(""))|exe "sil doau BufReadPost ".fnameescape(expand("")) au FileReadCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileReadPre ".fnameescape(expand(""))|call netrw#Nread(1,expand(""))|exe "sil doau FileReadPost ".fnameescape(expand("")) - au BufWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufWritePre ".fnameescape(expand(""))|exe 'Nwrite '.fnameescape(expand(""))|exe "sil doau BufWritePost ".fnameescape(expand("")) - au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileWritePre ".fnameescape(expand(""))|exe "'[,']".'Nwrite '.fnameescape(expand(""))|exe "sil doau FileWritePost ".fnameescape(expand("")) + au BufWriteCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufWritePre ".fnameescape(expand(""))|exe 'Nwrite '.fnameescape(expand(""))|exe "sil doau BufWritePost ".fnameescape(expand("")) + au FileWriteCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileWritePre ".fnameescape(expand(""))|exe "'[,']".'Nwrite '.fnameescape(expand(""))|exe "sil doau FileWritePost ".fnameescape(expand("")) try au SourceCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("")) catch /^Vim\%((\a\+)\)\=:E216/ @@ -64,8 +70,9 @@ com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()call netrw#NetRead( com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn(),call netrw#NetWrite()call netrw#NetrwRestorePosn() com! -nargs=* NetUserPass call NetUserPass() com! -nargs=* Nsource call netrw#NetrwSavePosn()call netrw#NetSource()call netrw#NetrwRestorePosn() +com! -nargs=? Ntree call netrw#NetrwSetTreetop() -" Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2 +" Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{2 com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(,0,0+0,) com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(,1,0+0,) com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(,1,2+0,) @@ -73,6 +80,7 @@ com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(,0,6 ,) com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,) com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,) +com! -nargs=* -bar -complete=dir Lexplore call netrw#Lexplore() " Commands: NetrwSettings {{{2 com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() @@ -83,36 +91,61 @@ if !exists("g:netrw_nogx") && maparg('gx','n') == "" if !hasmapto('NetrwBrowseX') nmap gx NetrwBrowseX endif - nno NetrwBrowseX :call netrw#NetrwBrowseX(expand(""),0) + nno NetrwBrowseX :call netrw#NetrwBrowseX(expand(""),0) endif " --------------------------------------------------------------------- -" LocalBrowse: {{{2 +" LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{2 fun! s:LocalBrowse(dirname) - " unfortunate interaction -- debugging calls can't be used here; - " the BufEnter event causes triggering when attempts to write to + " Unfortunate interaction -- only DechoMsg debugging calls can be safely used here. + " Otherwise, the BufEnter event gets triggered when attempts to write to " the DBG buffer are made. -" echomsg "dirname<".a:dirname.">" + + if !exists("s:vimentered") + " If s:vimentered doesn't exist, then the VimEnter event hasn't fired. It will, + " and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined. +" call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered doesn't exist)") +" call Dret("s:LocalBrowse") + return + endif + +" call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered=".s:vimentered.")") + if has("amiga") " The check against '' is made for the Amiga, where the empty " string is the current directory and not checking would break " things such as the help command. +" call Decho("(LocalBrowse) dirname<".a:dirname."> (isdirectory, amiga)") if a:dirname != '' && isdirectory(a:dirname) sil! call netrw#LocalBrowseCheck(a:dirname) endif + elseif isdirectory(a:dirname) -" echomsg "dirname<".dirname."> isdir" +" call Decho("(LocalBrowse) dirname<".a:dirname."> (isdirectory, not amiga)") sil! call netrw#LocalBrowseCheck(a:dirname) + + else + " not a directory, ignore it +" call Decho("(LocalBrowse) dirname<".a:dirname."> not a directory, ignoring...") endif - " not a directory, ignore it + +" call Dret("s:LocalBrowse") endfun " --------------------------------------------------------------------- -" s:VimEnter: {{{2 +" s:VimEnter: after all vim startup stuff is done, this function is called. {{{2 +" Its purpose: to look over all windows and run s:LocalBrowse() on +" them, which checks if they're directories and will create a directory +" listing when appropriate. +" It also sets s:vimentered, letting s:LocalBrowse() know that s:VimEnter() +" has already been called. fun! s:VimEnter(dirname) - let curwin= winnr() - windo if a:dirname != expand("%")|call s:LocalBrowse(expand("%:p"))|endif +" call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">") + let curwin = winnr() + let s:vimentered = 1 + windo call s:LocalBrowse(expand("%:p")) exe curwin."wincmd w" +" call Dret("s:VimEnter") endfun " --------------------------------------------------------------------- diff --git a/vimfiles/plugin/tcomment.vim b/vimfiles/plugin/tcomment.vim index aa53944..02f58c7 100644 --- a/vimfiles/plugin/tcomment.vim +++ b/vimfiles/plugin/tcomment.vim @@ -2,34 +2,50 @@ " @Author: Tom Link (micathom AT gmail com) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 27-Dez-2004. -" @Last Change: 2012-11-26. -" @Revision: 762 +" @Last Change: 2014-02-05. +" @Revision: 811 " GetLatestVimScripts: 1173 1 tcomment.vim if &cp || exists('loaded_tcomment') finish endif -let loaded_tcomment = 208 +let loaded_tcomment = 303 + +let s:save_cpo = &cpo +set cpo&vim + + +if !exists('g:tcommentMaps') + " If true, set maps. + let g:tcommentMaps = 1 "{{{2 +endif if !exists("g:tcommentMapLeader1") " g:tcommentMapLeader1 should be a shortcut that can be used with " map, imap, vmap. let g:tcommentMapLeader1 = '' "{{{2 endif + if !exists("g:tcommentMapLeader2") " g:tcommentMapLeader2 should be a shortcut that can be used with " map, xmap. let g:tcommentMapLeader2 = '_' "{{{2 endif + if !exists("g:tcommentMapLeaderOp1") " See |tcomment-operator|. let g:tcommentMapLeaderOp1 = 'gc' "{{{2 endif + if !exists("g:tcommentMapLeaderOp2") " See |tcomment-operator|. let g:tcommentMapLeaderOp2 = 'gC' "{{{2 endif +if !exists('g:tcommentTextObjectInlineComment') + let g:tcommentTextObjectInlineComment = 'ic' "{{{2 +endif + " :display: :[range]TComment[!] ?ARGS... " If there is a visual selection that begins and ends in the same line, @@ -96,62 +112,131 @@ command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TComme \ keepjumps call tcomment#Comment(, , 'i', "", ) +noremap TComment- :TComment +vnoremap TComment- :TCommentMaybeInline +inoremap TComment- :TComment +noremap TComment-p m`vip:TComment`` +inoremap TComment-p :norm! m`vip:TComment`` +noremap TComment- :TComment +inoremap TComment- :TComment +inoremap TComment-r :TCommentRight +noremap TComment-r :TCommentRight +vnoremap TComment-i :TCommentInline +noremap TComment-i v:TCommentInline mode=I# +inoremap TComment-i v:TCommentInline mode=# +noremap TComment-b :TCommentBlock +inoremap TComment-b :TCommentBlock mode=# +noremap TComment-a :TCommentAs +inoremap TComment-a :TCommentAs +noremap TComment-n :TCommentAs =&ft +inoremap TComment-n :TCommentAs =&ft +noremap TComment-s :TCommentAs =&ft_ +inoremap TComment-s :TCommentAs =&ft_ +noremap TComment-cc :call tcomment#SetOption("count", v:count1) +noremap TComment-ca :call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete")) -if (g:tcommentMapLeader1 != '') - exec 'noremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment' - exec 'vnoremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TCommentMaybeInline' - exec 'inoremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment' - exec 'noremap '. g:tcommentMapLeader1 .'p m`vip:TComment``' - exec 'inoremap '. g:tcommentMapLeader1 .'p :norm! m`vip:TComment``' - exec 'noremap '. g:tcommentMapLeader1 .' :TComment ' - exec 'inoremap '. g:tcommentMapLeader1 .' :TComment ' - exec 'inoremap '. g:tcommentMapLeader1 .'r :TCommentRight' - exec 'noremap '. g:tcommentMapLeader1 .'r :TCommentRight' - exec 'vnoremap '. g:tcommentMapLeader1 .'i :TCommentInline' - exec 'noremap '. g:tcommentMapLeader1 .'i v:TCommentInline mode=I#' - exec 'inoremap '. g:tcommentMapLeader1 .'i v:TCommentInline mode=#' - exec 'noremap '. g:tcommentMapLeader1 .'b :TCommentBlock' - exec 'inoremap '. g:tcommentMapLeader1 .'b :TCommentBlock' - exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs ' - exec 'inoremap '. g:tcommentMapLeader1 .'a :TCommentAs ' - exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' - exec 'inoremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' - exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' - exec 'inoremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' - exec 'noremap '. g:tcommentMapLeader1 .'cc :call tcomment#SetOption("count", v:count1)' - exec 'noremap '. g:tcommentMapLeader1 .'ca :call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))' - for s:i in range(1, 9) - exec 'noremap '. g:tcommentMapLeader1 . s:i .' :TComment count='. s:i .'' - exec 'inoremap '. g:tcommentMapLeader1 . s:i .' :TComment count='. s:i .'' - exec 'vnoremap '. g:tcommentMapLeader1 . s:i .' :TCommentMaybeInline count='. s:i .'' - endfor - unlet s:i -endif -if (g:tcommentMapLeader2 != '') - exec 'noremap '. g:tcommentMapLeader2 .'_ :TComment' - exec 'xnoremap '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline' - exec 'noremap '. g:tcommentMapLeader2 .'p vip:TComment' - exec 'noremap '. g:tcommentMapLeader2 .' :TComment ' - exec 'xnoremap '. g:tcommentMapLeader2 .'i :TCommentInline' - exec 'noremap '. g:tcommentMapLeader2 .'r :TCommentRight' - exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock' - exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs ' - exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs =&ft ' - exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs =&ft_' -endif -if (g:tcommentMapLeaderOp1 != '') - exec 'nnoremap '. g:tcommentMapLeaderOp1 .' :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operatorg@' - for s:i in range(1, 9) - exec 'nnoremap '. g:tcommentMapLeaderOp1 . s:i .'c :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("count", '. s:i .') \| set opfunc=tcomment#Operatorg@' - endfor - unlet s:i - exec 'nnoremap '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineg@$' - exec 'xnoremap '. g:tcommentMapLeaderOp1 .' :TCommentMaybeInline' -endif -if (g:tcommentMapLeaderOp2 != '') - exec 'nnoremap '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnywayg@' - exec 'nnoremap '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnywayg@$' - exec 'xnoremap '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline!' +noremap TComment-__ :TComment +xnoremap TComment-__ :TCommentMaybeInline +noremap TComment-_p vip:TComment +noremap TComment-_ :TComment +xnoremap TComment-_i :TCommentInline +noremap TComment-_r :TCommentRight +noremap TComment-_b :TCommentBlock +noremap TComment-_a :TCommentAs +noremap TComment-_n :TCommentAs =&ft +noremap TComment-_s :TCommentAs =&ft_ + +nnoremap TComment-gC :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnywayg@ +nnoremap TComment-gCc :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnywayg@$ +nnoremap TComment-gCb :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLineg@ +xnoremap TComment-gC :TCommentMaybeInline! + +vnoremap TComment-ic :call tcomment#TextObjectInlineComment() +noremap TComment-ic :call tcomment#TextObjectInlineComment() + +nnoremap TComment-gcc :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineg@$ +nnoremap TComment-gcb :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLineg@ +xnoremap TComment-gc :TCommentMaybeInline + +nnoremap TComment-gc :if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operatorg@ + +for s:i in range(1, 9) + exec 'noremap TComment-' . s:i . ' :call tcomment#SetOption("count", '. s:i .')' + exec 'inoremap TComment-' . s:i . ' :call tcomment#SetOption("count", '. s:i .')' + exec 'vnoremap TComment-' . s:i . ' :call tcomment#SetOption("count", '. s:i .')' +endfor +for s:i in range(1, 9) + exec 'nnoremap TComment-gc' . s:i .'c :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("count", '. s:i .') \| set opfunc=tcomment#Operatorg@' +endfor +unlet s:i + + +if g:tcommentMaps + if g:tcommentMapLeader1 != '' + exec 'map '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' TComment-' + exec 'vmap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' TComment-' + exec 'imap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' TComment-' + exec 'map '. g:tcommentMapLeader1 .'p TComment-p' + exec 'imap '. g:tcommentMapLeader1 .'p TComment-p' + exec 'map '. g:tcommentMapLeader1 .' TComment-' + exec 'imap '. g:tcommentMapLeader1 .' TComment-' + exec 'imap '. g:tcommentMapLeader1 .'r TComment-r' + exec 'map '. g:tcommentMapLeader1 .'r TComment-r' + exec 'vmap '. g:tcommentMapLeader1 .'i TComment-i' + exec 'map '. g:tcommentMapLeader1 .'i TComment-i' + exec 'imap '. g:tcommentMapLeader1 .'i TComment-i' + exec 'map '. g:tcommentMapLeader1 .'b TComment-b' + exec 'imap '. g:tcommentMapLeader1 .'b TComment-b' + exec 'map '. g:tcommentMapLeader1 .'a TComment-a' + exec 'imap '. g:tcommentMapLeader1 .'a TComment-a' + exec 'map '. g:tcommentMapLeader1 .'n TComment-n' + exec 'imap '. g:tcommentMapLeader1 .'n TComment-n' + exec 'map '. g:tcommentMapLeader1 .'s TComment-s' + exec 'imap '. g:tcommentMapLeader1 .'s TComment-s' + exec 'map '. g:tcommentMapLeader1 .'cc TComment-cc' + exec 'map '. g:tcommentMapLeader1 .'ca TComment-ca' + for s:i in range(1, 9) + exec 'map '. g:tcommentMapLeader1 . s:i .' TComment-'.s:i + exec 'imap '. g:tcommentMapLeader1 . s:i .' TComment-'.s:i + exec 'vmap '. g:tcommentMapLeader1 . s:i .' TComment-'.s:i + endfor + unlet s:i + endif + if g:tcommentMapLeader2 != '' + exec 'map '. g:tcommentMapLeader2 .'_ TComment-__' + exec 'xmap '. g:tcommentMapLeader2 .'_ TComment-__' + exec 'map '. g:tcommentMapLeader2 .'p TComment-_p' + exec 'map '. g:tcommentMapLeader2 .' TComment-_' + exec 'xmap '. g:tcommentMapLeader2 .'i TComment-_i' + exec 'map '. g:tcommentMapLeader2 .'r TComment-_r' + exec 'map '. g:tcommentMapLeader2 .'b TComment-_b' + exec 'map '. g:tcommentMapLeader2 .'a TComment-_a' + exec 'map '. g:tcommentMapLeader2 .'n TComment-_n' + exec 'map '. g:tcommentMapLeader2 .'s TComment-_s' + endif + if g:tcommentMapLeaderOp1 != '' + exec 'nmap '. g:tcommentMapLeaderOp1 .' TComment-gc' + for s:i in range(1, 9) + exec 'nmap '. g:tcommentMapLeaderOp1 . s:i .' TComment-gc'.s:i + endfor + unlet s:i + exec 'nmap '. g:tcommentMapLeaderOp1 .'c TComment-gcc' + exec 'nmap '. g:tcommentMapLeaderOp1 .'b TComment-gcb' + exec 'xmap '. g:tcommentMapLeaderOp1 .' TComment-gc' + endif + if g:tcommentMapLeaderOp2 != '' + exec 'nmap '. g:tcommentMapLeaderOp2 .' TComment-gC' + exec 'nmap '. g:tcommentMapLeaderOp2 .'c TComment-gCc' + exec 'nmap '. g:tcommentMapLeaderOp2 .'b TComment-gCb' + exec 'xmap '. g:tcommentMapLeaderOp2 .' TComment-gC' + endif + if g:tcommentTextObjectInlineComment != '' + exec 'vmap' g:tcommentTextObjectInlineComment ' TComment-ic' + exec 'omap' g:tcommentTextObjectInlineComment ' TComment-ic' + endif endif + +let &cpo = s:save_cpo +unlet s:save_cpo " vi: ft=vim:tw=72:ts=4:fo=w2croql diff --git a/vimfiles/syntax/netrw.vim b/vimfiles/syntax/netrw.vim index a319d7c..f049c5b 100644 --- a/vimfiles/syntax/netrw.vim +++ b/vimfiles/syntax/netrw.vim @@ -19,11 +19,12 @@ syn cluster NetrwTreeGroup contains=netrwDir,netrwSymLink,netrwExe syn match netrwPlain "\(\S\+ \)*\S\+" contains=@NoSpell syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell syn match netrwDir "\.\{1,2}/" contains=netrwClassify,@NoSpell -syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify,@NoSpell +"syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify,@NoSpell +syn match netrwDir "\%(\S\+ \)*\S\+/\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" skipwhite contains=netrwDateSep,@NoSpell nextgroup=netrwTime syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell syn match netrwExe "\%(\S\+ \)*\S*[^~]\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell -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