Mercurial > vim
comparison runtime/autoload/netrw.vim @ 829:dc8197342755 v7.0d04
updated for version 7.0d04
author | vimboss |
---|---|
date | Fri, 14 Apr 2006 20:42:25 +0000 |
parents | 01583c79d5f4 |
children | 1f3b1021f002 |
comparison
equal
deleted
inserted
replaced
828:01583c79d5f4 | 829:dc8197342755 |
---|---|
1 " netrw.vim: Handles file transfer and remote directory listing across a network | 1 " netrw.vim: Handles file transfer and remote directory listing across a network |
2 " AUTOLOAD PORTION | 2 " AUTOLOAD PORTION |
3 " Date: Apr 12, 2006 | 3 " Date: Apr 14, 2006 |
4 " Version: 87 | 4 " Version: 88 |
5 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> | 5 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> |
6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim | 6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
7 " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 | 7 " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 |
8 " Permission is hereby granted to use and distribute this code, | 8 " Permission is hereby granted to use and distribute this code, |
9 " with or without modifications, provided that this copyright | 9 " with or without modifications, provided that this copyright |
21 | 21 |
22 " Exception for &cp: {{{1 | 22 " Exception for &cp: {{{1 |
23 if &cp || exists("g:loaded_netrw") | 23 if &cp || exists("g:loaded_netrw") |
24 finish | 24 finish |
25 endif | 25 endif |
26 let g:loaded_netrw = "v87" | 26 let g:loaded_netrw = "v88" |
27 if v:version < 700 | 27 if v:version < 700 |
28 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None | 28 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None |
29 finish | 29 finish |
30 endif | 30 endif |
31 let s:keepcpo= &cpo | 31 let s:keepcpo= &cpo |
927 let b:netrw_lastfile = choice | 927 let b:netrw_lastfile = choice |
928 | 928 |
929 "......................................... | 929 "......................................... |
930 " ftp + <.netrc>: NetWrite Method #2 {{{3 | 930 " ftp + <.netrc>: NetWrite Method #2 {{{3 |
931 elseif b:netrw_method == 2 | 931 elseif b:netrw_method == 2 |
932 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) | 932 let netrw_fname= b:netrw_fname |
933 new | 933 new |
934 setlocal ff=unix | 934 setlocal ff=unix |
935 exe "put ='".g:netrw_ftpmode."'" | 935 exe "put ='".g:netrw_ftpmode."'" |
936 " call Decho(" filter input: ".getline(".")) | 936 " call Decho(" filter input: ".getline(".")) |
937 exe "put ='"."put ".tmpfile.' \"'.netrw_fname.'\"'."'" | 937 exe "put ='"."put ".tmpfile.' \"'.netrw_fname.'\"'."'" |
955 let b:netrw_lastfile = choice | 955 let b:netrw_lastfile = choice |
956 | 956 |
957 "......................................... | 957 "......................................... |
958 " ftp + machine, id, passwd, filename: NetWrite Method #3 {{{3 | 958 " ftp + machine, id, passwd, filename: NetWrite Method #3 {{{3 |
959 elseif b:netrw_method == 3 | 959 elseif b:netrw_method == 3 |
960 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) | 960 let netrw_fname= b:netrw_fname |
961 new | 961 new |
962 setlocal ff=unix | 962 setlocal ff=unix |
963 if exists("g:netrw_port") && g:netrw_port != "" | 963 if exists("g:netrw_port") && g:netrw_port != "" |
964 put ='open '.g:netrw_machine.' '.g:netrw_port | 964 put ='open '.g:netrw_machine.' '.g:netrw_port |
965 " call Decho("filter input: ".getline(".")) | 965 " call Decho("filter input: ".getline(".")) |
1406 endif | 1406 endif |
1407 endif | 1407 endif |
1408 | 1408 |
1409 " set up syntax highlighting | 1409 " set up syntax highlighting |
1410 if has("syntax") | 1410 if has("syntax") |
1411 setlocal ft=netrwlist | 1411 setlocal ft=netrw |
1412 if !exists("g:syntax_on") || !g:syntax_on | 1412 if !exists("g:syntax_on") || !g:syntax_on |
1413 setlocal ft= | 1413 setlocal ft= |
1414 " Ugly workaround -- when syntax highlighting is off and laststatus==2, | 1414 " Ugly workaround -- when syntax highlighting is off and laststatus==2, |
1415 " sometimes the laststatus highlight bleeds into the entire display. | 1415 " sometimes the laststatus highlight bleeds into the entire display. |
1416 " Only seems to happen with remote browsing. Weird. | 1416 " Only seems to happen with remote browsing. Weird. |
1921 " --------------------------------------------------------------------- | 1921 " --------------------------------------------------------------------- |
1922 " NetBrowseFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2 | 1922 " NetBrowseFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2 |
1923 " This function assumes that a long listing will be received. Size, time, | 1923 " This function assumes that a long listing will be received. Size, time, |
1924 " and reverse sorts will be requested of the server but not otherwise | 1924 " and reverse sorts will be requested of the server but not otherwise |
1925 " enforced here. | 1925 " enforced here. |
1926 fun! s:NetBrowseFtpCmd(path,cmd) | 1926 fun! s:NetBrowseFtpCmd(path,listcmd) |
1927 " call Dfunc("NetBrowseFtpCmd(path<".a:path."> cmd<".a:cmd.">) netrw_method=".w:netrw_method) | 1927 " call Dfunc("NetBrowseFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method) |
1928 | 1928 |
1929 " because WinXX ftp uses unix style input | 1929 " because WinXX ftp uses unix style input |
1930 " curline is one more than the bannercnt in order to account | 1930 " curline is one more than the bannercnt in order to account |
1931 " for the unwanted first blank line (doing a :put to an empty | 1931 " for the unwanted first blank line (doing a :put to an empty |
1932 " buffer yields a blank first line) | 1932 " buffer yields a blank first line) |
1940 " ftp + <.netrc>: Method #2 | 1940 " ftp + <.netrc>: Method #2 |
1941 if a:path != "" | 1941 if a:path != "" |
1942 put ='cd \"'.a:path.'\"' | 1942 put ='cd \"'.a:path.'\"' |
1943 " call Decho('ftp: '.getline(".")) | 1943 " call Decho('ftp: '.getline(".")) |
1944 endif | 1944 endif |
1945 exe "put ='".a:cmd."'" | 1945 exe "put ='".a:listcmd."'" |
1946 " call Decho("ftp: ".getline(".")) | 1946 " call Decho("ftp: ".getline(".")) |
1947 " redraw!|call inputsave()|call input("Pausing...")|call inputrestore() | 1947 " redraw!|call inputsave()|call input("Pausing...")|call inputrestore() |
1948 if exists("g:netrw_port") && g:netrw_port != "" | 1948 if exists("g:netrw_port") && g:netrw_port != "" |
1949 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) | 1949 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) |
1950 exe g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port | 1950 exe g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port |
1971 endif | 1971 endif |
1972 | 1972 |
1973 if a:path != "" | 1973 if a:path != "" |
1974 put ='cd \"'.a:path.'\"' | 1974 put ='cd \"'.a:path.'\"' |
1975 endif | 1975 endif |
1976 exe "put ='".a:cmd."'" | 1976 exe "put ='".a:listcmd."'" |
1977 | 1977 |
1978 " perform ftp: | 1978 " perform ftp: |
1979 " -i : turns off interactive prompting from ftp | 1979 " -i : turns off interactive prompting from ftp |
1980 " -n unix : DON'T use <.netrc>, even though it exists | 1980 " -n unix : DON'T use <.netrc>, even though it exists |
1981 " -n win32: quit being obnoxious about password | 1981 " -n win32: quit being obnoxious about password |
1989 | 1989 |
1990 " cleanup for Windows | 1990 " cleanup for Windows |
1991 if has("win32") || has("win95") || has("win64") || has("win16") | 1991 if has("win32") || has("win95") || has("win64") || has("win16") |
1992 silent! keepjumps! %s/\r$//e | 1992 silent! keepjumps! %s/\r$//e |
1993 endif | 1993 endif |
1994 if a:cmd == "dir" | 1994 if a:listcmd == "dir" |
1995 " infer directory/link based on the file permission string | 1995 " infer directory/link based on the file permission string |
1996 silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@ | 1996 silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@ |
1997 silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/ | 1997 silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/ |
1998 if w:netrw_longlist == 0 || w:netrw_longlist == 2 | 1998 if w:netrw_longlist == 0 || w:netrw_longlist == 2 |
1999 exe "silent! keepjumps ".curline.',$s/^\%(\S\+\s\+\)\{8}//e' | 1999 exe "silent! keepjumps ".curline.',$s/^\%(\S\+\s\+\)\{8}//e' |
2135 endfun | 2135 endfun |
2136 | 2136 |
2137 " --------------------------------------------------------------------- | 2137 " --------------------------------------------------------------------- |
2138 " NetrwWideListing: {{{2 | 2138 " NetrwWideListing: {{{2 |
2139 fun! s:NetrwWideListing() | 2139 fun! s:NetrwWideListing() |
2140 " call Dfunc("NetrwWideListing() w:netrw_longlist=".w:netrw_longlist) | |
2141 | 2140 |
2142 if w:netrw_longlist == 2 | 2141 if w:netrw_longlist == 2 |
2142 " call Dfunc("NetrwWideListing() w:netrw_longlist=".w:netrw_longlist) | |
2143 " look for longest filename (cpf=characters per filename) | 2143 " look for longest filename (cpf=characters per filename) |
2144 " cpf: characters per file | 2144 " cpf: characters per file |
2145 " fpl: files per line | 2145 " fpl: files per line |
2146 " fpc: files per column | 2146 " fpc: files per column |
2147 set ma | 2147 set ma |
2180 exe "silent keepjumps ".newcolstart.','.newcolend.'d' | 2180 exe "silent keepjumps ".newcolstart.','.newcolend.'d' |
2181 exe 'silent keepjumps '.w:netrw_bannercnt | 2181 exe 'silent keepjumps '.w:netrw_bannercnt |
2182 endwhile | 2182 endwhile |
2183 exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e' | 2183 exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e' |
2184 setlocal noma nomod | 2184 setlocal noma nomod |
2185 endif | 2185 " call Dret("NetrwWideListing") |
2186 | 2186 endif |
2187 " call Dret("NetrwWideListing") | 2187 |
2188 endfun | 2188 endfun |
2189 | 2189 |
2190 " --------------------------------------------------------------------- | 2190 " --------------------------------------------------------------------- |
2191 " NetSaveWordPosn: used by the "s" command in both remote and local {{{2 | 2191 " NetSaveWordPosn: used by the "s" command in both remote and local {{{2 |
2192 " browsing. Along with NetRestoreWordPosn(), it keeps the cursor on | 2192 " browsing. Along with NetRestoreWordPosn(), it keeps the cursor on |
2648 | 2648 |
2649 " --------------------------------------------------------------------- | 2649 " --------------------------------------------------------------------- |
2650 " NetMenu: generates the menu for gvim and netrw {{{2 | 2650 " NetMenu: generates the menu for gvim and netrw {{{2 |
2651 fun! s:NetMenu(domenu) | 2651 fun! s:NetMenu(domenu) |
2652 | 2652 |
2653 if !exists("g:NetrwMenuPriority") | |
2654 let g:NetrwMenuPriority= 80 | |
2655 endif | |
2656 | |
2653 if has("menu") && has("gui_running") && &go =~ 'm' | 2657 if has("menu") && has("gui_running") && &go =~ 'm' |
2654 " call Dfunc("NetMenu(domenu=".a:domenu.")") | 2658 " call Dfunc("NetMenu(domenu=".a:domenu.")") |
2655 if !exists("s:netrw_menu_enabled") && a:domenu | 2659 if !exists("s:netrw_menu_enabled") && a:domenu |
2656 " call Decho("initialize menu") | 2660 " call Decho("initialize menu") |
2657 let s:netrw_menu_enabled= 1 | 2661 let s:netrw_menu_enabled= 1 |
2658 if !exists("g:NetrwTopLvlMenu") | 2662 if !exists("g:NetrwTopLvlMenu") |
2659 let g:NetrwTopLvlMenu= "Netrw." | 2663 let g:NetrwTopLvlMenu= "Netrw." |
2660 endif | 2664 endif |
2661 exe 'silent! menu '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>' | 2665 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>' |
2662 exe 'silent! menu '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x' | 2666 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x' |
2663 exe 'silent! menu '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory<tab>b Nb' | 2667 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory<tab>b Nb' |
2664 exe 'silent! menu '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -' | 2668 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -' |
2665 exe 'silent! menu '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory<tab>B NB' | 2669 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory<tab>B NB' |
2666 exe 'silent! menu '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory<tab>u u' | 2670 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory<tab>u u' |
2667 exe 'silent! menu '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory<tab>U U' | 2671 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory<tab>U U' |
2668 exe 'silent! menu '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D' | 2672 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D' |
2669 exe 'silent! menu '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List<tab>'."<ctrl-h> \<c-h>" | 2673 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List<tab>'."<ctrl-h> \<c-h>" |
2670 exe 'silent! menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory<tab><cr> '."\<cr>" | 2674 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory<tab><cr> '."\<cr>" |
2671 exe 'silent! menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window<tab>o o' | 2675 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window<tab>o o' |
2672 exe 'silent! menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window<tab>v v' | 2676 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window<tab>v v' |
2673 exe 'silent! menu '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History<tab>q q' | 2677 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History<tab>q q' |
2674 exe 'silent! menu '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)<tab>i i' | 2678 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)<tab>i i' |
2675 exe 'silent! menu '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d' | 2679 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d' |
2676 exe 'silent! menu '.g:NetrwTopLvlMenu.'Normal-Hide-Show<tab>a a' | 2680 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Normal-Hide-Show<tab>a a' |
2677 exe 'silent! menu '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O' | 2681 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O' |
2678 exe 'silent! menu '.g:NetrwTopLvlMenu.'Preview\ File/Directory<tab>p p' | 2682 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Preview\ File/Directory<tab>p p' |
2679 exe 'silent! menu '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser<tab>P P' | 2683 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser<tab>P P' |
2680 exe 'silent! menu '.g:NetrwTopLvlMenu.'Refresh\ Listing<tab>'."<ctrl-l> \<c-l>" | 2684 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Refresh\ Listing<tab>'."<ctrl-l> \<c-l>" |
2681 exe 'silent! menu '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R' | 2685 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R' |
2682 exe 'silent! menu '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order<tab>'."r r" | 2686 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order<tab>'."r r" |
2683 exe 'silent! menu '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style<tab>s s' | 2687 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style<tab>s s' |
2684 exe 'silent! menu '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit<tab>S S' | 2688 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit<tab>S S' |
2685 exe 'silent! menu '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c' | 2689 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c' |
2686 exe 'silent! menu '.g:NetrwTopLvlMenu.'Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>" | 2690 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>" |
2687 elseif !a:domenu | 2691 elseif !a:domenu |
2688 let s:netrwcnt = 0 | 2692 let s:netrwcnt = 0 |
2689 let curwin = winnr() | 2693 let curwin = winnr() |
2690 windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif | 2694 windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif |
2691 exe curwin."wincmd w" | 2695 exe curwin."wincmd w" |
2970 " generate the requested directory listing | 2974 " generate the requested directory listing |
2971 call s:LocalBrowseList() | 2975 call s:LocalBrowseList() |
2972 | 2976 |
2973 " set up syntax highlighting | 2977 " set up syntax highlighting |
2974 if has("syntax") | 2978 if has("syntax") |
2975 setlocal ft=netrwlist | 2979 setlocal ft=netrw |
2976 if !exists("g:syntax_on") || !g:syntax_on | 2980 if !exists("g:syntax_on") || !g:syntax_on |
2977 setlocal ft= | 2981 setlocal ft= |
2978 endif | 2982 endif |
2979 endif | 2983 endif |
2980 | 2984 |