Mercurial > vim
annotate runtime/plugin/netrwPlugin.vim @ 4339:22fa3049e934
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 24 Apr 2013 18:51:19 +0200 |
parents | c53344bacabf |
children | 605c9ce57ec3 |
rev | line source |
---|---|
534 | 1 " netrwPlugin.vim: Handles file transfer and remote directory listing across a network |
1118 | 2 " PLUGIN SECTION |
4339 | 3 " Date: Dec 06, 2012 |
4 " Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> | |
534 | 5 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
4339 | 6 " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 |
534 | 7 " Permission is hereby granted to use and distribute this code, |
8 " with or without modifications, provided that this copyright | |
9 " notice is copied with it. Like anything else that's free, | |
10 " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided | |
11 " *as is* and comes with no warranty of any kind, either | |
12 " expressed or implied. By using this plugin, you agree that | |
13 " in no event will the copyright holder be liable for any damages | |
14 " resulting from the use of this software. | |
15 " | |
16 " But be doers of the Word, and not only hearers, deluding your own selves {{{1 | |
17 " (James 1:22 RSV) | |
18 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | |
19 " Load Once: {{{1 | |
1118 | 20 if &cp || exists("g:loaded_netrwPlugin") |
534 | 21 finish |
22 endif | |
4339 | 23 let g:loaded_netrwPlugin = "v148" |
2034 | 24 if v:version < 702 |
25 echohl WarningMsg | echo "***netrw*** you need vim version 7.2 for this version of netrw" | echohl None | |
553 | 26 finish |
27 endif | |
2034 | 28 let s:keepcpo = &cpo |
534 | 29 set cpo&vim |
30 | |
31 " --------------------------------------------------------------------- | |
32 " Public Interface: {{{1 | |
33 | |
34 " Local Browsing: {{{2 | |
35 augroup FileExplorer | |
36 au! | |
2751 | 37 " au BufReadCmd *[/\\] sil! call s:LocalBrowse(expand("<amatch>")) |
38 " au BufEnter *[^/\\] sil! call s:LocalBrowse(expand("<amatch>")) | |
39 " au VimEnter *[^/\\] sil! call s:VimEnter(expand("<amatch>")) | |
40 au BufEnter * sil! call s:LocalBrowse(expand("<amatch>")) | |
41 au VimEnter * sil! call s:VimEnter(expand("<amatch>")) | |
1118 | 42 if has("win32") || has("win95") || has("win64") || has("win16") |
2751 | 43 au BufEnter .* sil! call s:LocalBrowse(expand("<amatch>")) |
1118 | 44 endif |
534 | 45 augroup END |
46 | |
47 " Network Browsing Reading Writing: {{{2 | |
48 augroup Network | |
49 au! | |
3153 | 50 au BufReadCmd file://* call netrw#FileUrlRead(expand("<amatch>")) |
4339 | 51 au BufReadCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "sil doau BufReadPost ".fnameescape(expand("<amatch>")) |
52 au FileReadCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(1,expand("<amatch>"))|exe "sil doau FileReadPost ".fnameescape(expand("<amatch>")) | |
53 au BufWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>")) | |
54 au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau FileWritePost ".fnameescape(expand("<amatch>")) | |
1118 | 55 try |
3153 | 56 au SourceCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) |
1118 | 57 catch /^Vim\%((\a\+)\)\=:E216/ |
3153 | 58 au SourcePre ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) |
1118 | 59 endtry |
534 | 60 augroup END |
61 | |
62 " Commands: :Nread, :Nwrite, :NetUserPass {{{2 | |
1618 | 63 com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#NetrwRestorePosn() |
64 com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetrwRestorePosn() | |
534 | 65 com! -nargs=* NetUserPass call NetUserPass(<f-args>) |
1618 | 66 com! -nargs=* Nsource call netrw#NetrwSavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#NetrwRestorePosn() |
534 | 67 |
68 " Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2 | |
1118 | 69 com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>) |
70 com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>) | |
71 com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>) | |
72 com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>) | |
73 com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>) | |
74 com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>) | |
75 com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>) | |
534 | 76 |
77 " Commands: NetrwSettings {{{2 | |
1618 | 78 com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() |
79 com! -bang NetrwClean call netrw#NetrwClean(<bang>0) | |
534 | 80 |
649 | 81 " Maps: |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
82 if !exists("g:netrw_nogx") && maparg('gx','n') == "" |
1118 | 83 if !hasmapto('<Plug>NetrwBrowseX') |
84 nmap <unique> gx <Plug>NetrwBrowseX | |
85 endif | |
1618 | 86 nno <silent> <Plug>NetrwBrowseX :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<cr> |
649 | 87 endif |
88 | |
534 | 89 " --------------------------------------------------------------------- |
90 " LocalBrowse: {{{2 | |
91 fun! s:LocalBrowse(dirname) | |
92 " unfortunate interaction -- debugging calls can't be used here; | |
93 " the BufEnter event causes triggering when attempts to write to | |
94 " the DBG buffer are made. | |
1118 | 95 " echomsg "dirname<".a:dirname.">" |
96 if has("amiga") | |
97 " The check against '' is made for the Amiga, where the empty | |
98 " string is the current directory and not checking would break | |
99 " things such as the help command. | |
100 if a:dirname != '' && isdirectory(a:dirname) | |
2751 | 101 sil! call netrw#LocalBrowseCheck(a:dirname) |
1118 | 102 endif |
103 elseif isdirectory(a:dirname) | |
104 " echomsg "dirname<".dirname."> isdir" | |
2751 | 105 sil! call netrw#LocalBrowseCheck(a:dirname) |
534 | 106 endif |
107 " not a directory, ignore it | |
108 endfun | |
109 | |
110 " --------------------------------------------------------------------- | |
2152 | 111 " s:VimEnter: {{{2 |
112 fun! s:VimEnter(dirname) | |
2426 | 113 let curwin= winnr() |
2152 | 114 windo if a:dirname != expand("%")|call s:LocalBrowse(expand("%:p"))|endif |
2426 | 115 exe curwin."wincmd w" |
2152 | 116 endfun |
117 | |
118 " --------------------------------------------------------------------- | |
534 | 119 " NetrwStatusLine: {{{1 |
120 fun! NetrwStatusLine() | |
755 | 121 " let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".") |
122 if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list") | |
534 | 123 let &stl= s:netrw_explore_stl |
124 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif | |
125 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif | |
126 return "" | |
127 else | |
128 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen | |
129 endif | |
130 endfun | |
131 | |
132 " ------------------------------------------------------------------------ | |
133 " NetUserPass: set username and password for subsequent ftp transfer {{{1 | |
134 " Usage: :call NetUserPass() -- will prompt for userid and password | |
135 " :call NetUserPass("uid") -- will prompt for password | |
136 " :call NetUserPass("uid","password") -- sets global userid and password | |
137 fun! NetUserPass(...) | |
138 | |
139 " get/set userid | |
140 if a:0 == 0 | |
141 " call Dfunc("NetUserPass(a:0<".a:0.">)") | |
142 if !exists("g:netrw_uid") || g:netrw_uid == "" | |
143 " via prompt | |
144 let g:netrw_uid= input('Enter username: ') | |
145 endif | |
146 else " from command line | |
147 " call Dfunc("NetUserPass(a:1<".a:1.">) {") | |
148 let g:netrw_uid= a:1 | |
149 endif | |
150 | |
151 " get password | |
152 if a:0 <= 1 " via prompt | |
153 " call Decho("a:0=".a:0." case <=1:") | |
154 let g:netrw_passwd= inputsecret("Enter Password: ") | |
155 else " from command line | |
156 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">") | |
157 let g:netrw_passwd=a:2 | |
158 endif | |
159 " call Dret("NetUserPass") | |
160 endfun | |
161 | |
162 " ------------------------------------------------------------------------ | |
163 " Modelines And Restoration: {{{1 | |
164 let &cpo= s:keepcpo | |
165 unlet s:keepcpo | |
166 " vim:ts=8 fdm=marker |