Skip to content

Commit f731124

Browse files
authored
Merge pull request #1773 from h-east/update-pi_netrw
Update pi_netrw.{txt,jax}
2 parents 793f438 + 36c2ef8 commit f731124

File tree

2 files changed

+181
-64
lines changed

2 files changed

+181
-64
lines changed

doc/pi_netrw.jax

Lines changed: 93 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*pi_netrw.txt* For Vim バージョン 9.1. Last change: 2024 Oct 21
1+
*pi_netrw.txt* For Vim バージョン 9.1. Last change: 2024 Nov 09
22

33
------------------------------------------------
44
NETRW REFERENCE MANUAL by Charles E. Campbell
@@ -8,7 +8,7 @@ Author: Charles E. Campbell <[email protected]>
88

99
Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
1010
The VIM LICENSE applies to the files in this package, including
11-
netrw.vim, pi_netrw.txt, netrwFileHandlers.vim, netrwSettings.vim, and
11+
netrw.vim, pi_netrw.txt, netrwSettings.vim, and
1212
syntax/netrw.vim. Like anything else that's free, netrw.vim and its
1313
associated files are provided *as is* and comes with no warranty of
1414
any kind, either expressed or implied. No guarantees of
@@ -55,9 +55,10 @@ Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
5555
水平分割ウィンドウを使ったブラウジング..............|netrw-o|
5656
タブを使ったブラウジング............................|netrw-t|
5757
垂直分割ウィンドウを使ったブラウジング..............|netrw-v|
58-
ファイルの権限を変更................................|netrw-gp|
5958
一覧表示スタイル変更 (thin wide long tree)..........|netrw-i|
6059
ブックマークしたディレクトリに移動..................|netrw-gb|
60+
ドットファイルのクイック表示/非表示.................|netrw-gh|
61+
ローカルのみのファイル権限の変更....................|netrw-gp|
6162
前方のディレクトリに移動............................|netrw-u|
6263
後方のディレクトリに移動............................|netrw-U|
6364
特殊ハンドラでブラウジングをカスタマイズ............|netrw-x|
@@ -1434,49 +1435,106 @@ NETRW CLEAN *netrw-clean* *:NetrwClean* {{{2
14341435
どちらのコマンドも、本当に削除していいかどうかを確認するダイアログが最初に表示
14351436
されます。ファイルを削除する権限がない場合はエラーメッセージが表示されます。
14361437

1437-
*netrw-gx*
14381438
☆特殊ハンドラでブラウジングをカスタマイズ *netrw-x* *netrw-handler* {{{2
14391439

14401440
html, gif, jpeg, (word/office) doc などのファイルは専用ハンドラ (コンピュータ
14411441
にあらかじめ備わっているようなツール) で処理するのが一番です。Netrw ではそのよ
1442-
うな専用ハンドラの呼び出しをサポートしています: >
1442+
うな専用ハンドラの呼び出しをサポートしています:
1443+
1444+
* ファイルパスの上にあるカーソルで gx を押すか、netrw バッファで x を
1445+
押す。前者は |g:netrw_nogx| 変数を定義することで無効にできます。
1446+
* コマンド ラインで、:Open <path> と入力します。下記 |:Open| を参照。
1447+
1448+
ビジュアルモード (|visual-start| を参照) を使用して、特殊ハンドラが使用するテ
1449+
キストを選択することもできます。通常、gx はカーソルの下のテキストを取得するた
1450+
めに近くの URL またはファイル名をチェックします。|expand()| が使用するテキスト
1451+
は、|g:netrw_gx| 変数 (オプションには "<cword>"、"<cWORD>" が含まれます) を介
1452+
して変更できます。Note expand("<cfile>") は、|'isfname'| の設定に依存すること
1453+
に注意してください。または、ビジュアル選択 (|visual-block| を参照) を行ってか
1454+
ら gx を押すことで、gx が使用するテキストを選択することもできます。
1455+
1456+
選択関数は、関数 `Netrw_get_URL_<filetype>` を追加することで各ファイルタイプに
1457+
適応できます。<filetype>'filetype' で指定します。
1458+
この関数は、gx が使用する URL またはファイル名を返す必要があり、空の文字列を返
1459+
す場合はデフォルトの動作に戻ります。
1460+
例えば、Markdown と HTML のリンク用の特別なハンドラは、
1461+
>
1462+
" 正確なカーソル位置に関係なく、gx が concealed なリンクで動作するようにする: >
1463+
1464+
function Netrw_get_URL_markdown()
1465+
" 次のような markdown URL [link text](http://ya.ru 'yandex search')
1466+
try
1467+
let save_view = winsaveview()
1468+
if searchpair('\[.\{-}\](', '', ')\zs', 'cbW', '', line('.')) > 0
1469+
return matchstr(getline('.')[col('.')-1:],
1470+
\ '\[.\{-}\](\zs' .. g:netrw_regex_url .. '\ze\(\s\+.\{-}\)\?)')
1471+
endif
1472+
finally
1473+
call winrestview(save_view)
1474+
return ''
1475+
endtry
1476+
endfunction
1477+
1478+
function Netrw_get_URL_html()
1479+
" 次のような HTML URL <a href='http://www.python.org'>Python is here</a>
1480+
" <a href="http://www.python.org"/>
1481+
try
1482+
let save_view = winsaveview()
1483+
if searchpair('<a\s\+href=', '', '\%(</a>\|/>\)\zs', 'cbW', '', line('.')) > 0
1484+
return matchstr(getline('.')[col('.') - 1 : ],
1485+
\ 'href=["'.."'"..']\?\zs\S\{-}\ze["'.."'"..']\?/\?>')
1486+
endif
1487+
finally
1488+
call winrestview(save_view)
1489+
return ''
1490+
endtry
1491+
endfunction
1492+
<
1493+
ファイルパス以外に、カーソルの下のテキストが URL である場合もあります。Netrw
1494+
は、デフォルトで次の正規表現を使用して、カーソルの下のテキストが URL であるか
1495+
どうかを判断します。
1496+
>
1497+
:let g:netrw_regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}'
1498+
<
1499+
関連する設定変数:
1500+
|g:netrw_gx| gx がカーソルの下のテキストを取得する方法を制御する
1501+
|g:netrw_nogx| 編集中に gx マップを防止する
1502+
|g:netrw_suppress_gx_mesg| gx のブラウザーメッセージの抑制を制御する
1503+
1504+
☆ファイルを開いてアプリを起動する *netrw-gx* *:Open* *:Launch* {{{2
14431505

1444-
* ファイル一覧表示中に "x" キーを押す
1445-
* ファイルを開いているときに、ファイル名の上で gx を押す
1446-
< (後ろは |g:netrw_nogx| が設定されている場合は使えません)
1506+
Netrw は、次の方法で特殊ハンドラを決定します:
14471507

1448-
Netrw は次の方法で専用ハンドラを決定します:
1508+
* |g:netrw_browsex_viewer| が存在する場合、それを使用してファイルを表示しよ
1509+
うとします。
1510+
使用したいビューアがリモート URL ディレクトリの処理をサポートしていない場
1511+
合は、|g:netrw_browsex_support_remote| を 0 に設定します。
1512+
* 上記以外:
14491513

1450-
* |g:netrw_browsex_viewer| が設定されているときは、それを使ってファイルを開
1451-
きます。例えば次のような設定が便利です (<.vimrc>で設定する): >
1514+
* Windows では : explorer.exe が使用されます
1515+
* Mac OS X では : open が使用されます
1516+
* Linux では : xdg-open が使用されます
14521517

1453-
:let g:netrw_browsex_viewer= "kfmclient exec"
1454-
< or >
1455-
:let g:netrw_browsex_viewer= "xdg-open"
1518+
適切なハンドラでパス (または URL) <path> を開くには、以下を入力します。 >
1519+
1520+
:Open <path>
14561521
<
1457-
もし、使いたいビューアがリモートURLディレクトリの処理をサポートしていない場合は、
1458-
|g:netrw_browsex_support_remote| を 0 に設定してください。
1459-
* Windows 32 or 64 では、URL と FileProtocolHandler dll が使われます。
1460-
* Gnome (with gnome-open): gnome-open が使われます。
1461-
* KDE (with kfmclient) : kfmclient が使われます。
1462-
* Mac OS X : open が使われます。
1463-
1464-
gx マッピングはすべてのバッファに適用できます。カーソル位置の単語に "gx" を適
1465-
用すると、それに対し netrw は特別な処置を行います (ちょうど "x" が netrw バッ
1466-
ファに対して行うように)。特別な処置を行うテキストをビジュアルモード
1467-
(|visual-start| 参照) により選択することもできます。通常 gx はカーソル位置のテ
1468-
キストを取得するのに expand("<cfile>") を使用しますが、|g:netrw_gx| 変数で
1469-
|expand()| が使用する引数を変えることができます ("<cword>", "<cWORD>" を含むオ
1470-
プション)。Note: expand("<cfile>") は |'isfname'| の設定に依存します。また、代
1471-
わりに gx で使用するテキストをビジュアル選択を行っておき (|visual-block|
1472-
照)、その後 gx を押す方法でもよいです。
1522+
シェルでも Vim のコマンドラインでもエスケープは必要ありません。
14731523

1474-
関連設定:
1475-
|g:netrw_gx| gx がどのようにカーソル位置のテキストを取得するか制御
1476-
する
1477-
|g:netrw_nogx| 編集中 gx マップを無効にする
1478-
|g:netrw_suppress_gx_mesg| gx がブラウザーの出力を抑制するか制御する
1524+
特定のアプリケーションを起動するには、<app> <args>、多くの場合、<args>
1525+
<path> です >
1526+
1527+
:Launch <app> <args>.
14791528
1529+
<<args> は作為的に複雑になる可能性があり、特に多くのファイルパスが含まれる場
1530+
合、エスケープはユーザーに任されます。
1531+
1532+
g:loaded_netrwPlugin を設定して netrw プラグインを無効にした場合
1533+
(|netrw-noload| を参照) は、以下が使用できます >
1534+
1535+
:call netrw#Launch('<app> <args>')
1536+
:call netrw#Open('<path>')
1537+
<
14801538
*netrw-curdir*
14811539
☆ブックマークを削除する *netrw-mB* {{{2
14821540

en/pi_netrw.txt

Lines changed: 88 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*pi_netrw.txt* For Vim version 9.1. Last change: 2024 Oct 21
1+
*pi_netrw.txt* For Vim version 9.1. Last change: 2024 Nov 09
22

33
------------------------------------------------
44
NETRW REFERENCE MANUAL by Charles E. Campbell
@@ -8,7 +8,7 @@ Author: Charles E. Campbell <[email protected]>
88

99
Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
1010
The VIM LICENSE applies to the files in this package, including
11-
netrw.vim, pi_netrw.txt, netrwFileHandlers.vim, netrwSettings.vim, and
11+
netrw.vim, pi_netrw.txt, netrwSettings.vim, and
1212
syntax/netrw.vim. Like anything else that's free, netrw.vim and its
1313
associated files are provided *as is* and comes with no warranty of
1414
any kind, either expressed or implied. No guarantees of
@@ -54,9 +54,10 @@ Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
5454
Browsing With A Horizontally Split Window...........|netrw-o|
5555
Browsing With A New Tab.............................|netrw-t|
5656
Browsing With A Vertically Split Window.............|netrw-v|
57-
Change File Permission..............................|netrw-gp|
58-
Change Listing Style.(thin wide long tree)..........|netrw-i|
57+
Change Listing Style (thin wide long tree)..........|netrw-i|
5958
Changing To A Bookmarked Directory..................|netrw-gb|
59+
Quick hide/unhide of dot-files......................|netrw-gh|
60+
Changing local-only File Permission.................|netrw-gp|
6061
Changing To A Predecessor Directory.................|netrw-u|
6162
Changing To A Successor Directory...................|netrw-U|
6263
Customizing Browsing With A Special Handler.........|netrw-x|
@@ -1469,48 +1470,106 @@ With either form of the command, netrw will first ask for confirmation
14691470
that the removal is in fact what you want to do. If netrw doesn't have
14701471
permission to remove a file, it will issue an error message.
14711472

1472-
*netrw-gx*
14731473
CUSTOMIZING BROWSING WITH A SPECIAL HANDLER *netrw-x* *netrw-handler* {{{2
14741474

14751475
Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are
14761476
best seen with a special handler (ie. a tool provided with your computer's
1477-
operating system). Netrw allows one to invoke such special handlers by: >
1477+
operating system). Netrw allows one to invoke such special handlers by:
14781478

1479-
* when Exploring, hit the "x" key
1480-
* when editing, hit gx with the cursor atop the special filename
1481-
< (latter not available if the |g:netrw_nogx| variable exists)
1479+
* hitting gx with the cursor atop the file path or alternatively x
1480+
in a netrw buffer; the former can be disabled by defining the
1481+
|g:netrw_nogx| variable
1482+
* when in command line, typing :Open <path>, see |:Open| below.
14821483

1483-
Netrw determines which special handler by the following method:
1484-
1485-
* if |g:netrw_browsex_viewer| exists, then it will be used to attempt to
1486-
view files. Examples of useful settings (place into your <.vimrc>): >
1487-
1488-
:let g:netrw_browsex_viewer= "kfmclient exec"
1489-
< or >
1490-
:let g:netrw_browsex_viewer= "xdg-open"
1491-
<
1492-
If the viewer you wish to use does not support handling of a remote URL
1493-
directory, set |g:netrw_browsex_support_remote| to 0.
1494-
* for Windows 32 or 64, the URL and FileProtocolHandler dlls are used.
1495-
* for Gnome (with gnome-open): gnome-open is used.
1496-
* for KDE (with kfmclient) : kfmclient is used
1497-
* for Mac OS X : open is used.
1498-
1499-
The gx mapping extends to all buffers; apply "gx" while atop a word and netrw
1500-
will apply a special handler to it (like "x" works when in a netrw buffer).
15011484
One may also use visual mode (see |visual-start|) to select the text that the
1502-
special handler will use. Normally gx uses expand("<cfile>") to pick up the
1503-
text under the cursor; one may change what |expand()| uses via the
1485+
special handler will use. Normally gx checks for a close-by URL or file name
1486+
to pick up the text under the cursor; one may change what |expand()| uses via the
15041487
|g:netrw_gx| variable (options include "<cword>", "<cWORD>"). Note that
15051488
expand("<cfile>") depends on the |'isfname'| setting. Alternatively, one may
15061489
select the text to be used by gx by making a visual selection (see
15071490
|visual-block|) and then pressing gx.
15081491

1492+
The selection function can be adapted for each filetype by adding a function
1493+
`Netrw_get_URL_<filetype>`, where <filetype> is given by the 'filetype'.
1494+
The function should return the URL or file name to be used by gx, and will
1495+
fall back to the default behavior if it returns an empty string.
1496+
For example, special handlers for links Markdown and HTML are
1497+
1498+
" make gx work on concealed links regardless of exact cursor position: >
1499+
1500+
function Netrw_get_URL_markdown()
1501+
" markdown URL such as [link text](http://ya.ru 'yandex search')
1502+
try
1503+
let save_view = winsaveview()
1504+
if searchpair('\[.\{-}\](', '', ')\zs', 'cbW', '', line('.')) > 0
1505+
return matchstr(getline('.')[col('.')-1:],
1506+
\ '\[.\{-}\](\zs' .. g:netrw_regex_url .. '\ze\(\s\+.\{-}\)\?)')
1507+
endif
1508+
finally
1509+
call winrestview(save_view)
1510+
return ''
1511+
endtry
1512+
endfunction
1513+
1514+
function Netrw_get_URL_html()
1515+
" HTML URL such as <a href='http://www.python.org'>Python is here</a>
1516+
" <a href="http://www.python.org"/>
1517+
try
1518+
let save_view = winsaveview()
1519+
if searchpair('<a\s\+href=', '', '\%(</a>\|/>\)\zs', 'cbW', '', line('.')) > 0
1520+
return matchstr(getline('.')[col('.') - 1 : ],
1521+
\ 'href=["'.."'"..']\?\zs\S\{-}\ze["'.."'"..']\?/\?>')
1522+
endif
1523+
finally
1524+
call winrestview(save_view)
1525+
return ''
1526+
endtry
1527+
endfunction
1528+
<
1529+
Other than a file path, the text under the cursor may be a URL. Netrw uses
1530+
by default the following regular expression to determine if the text under the
1531+
cursor is a URL:
1532+
>
1533+
:let g:netrw_regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}'
1534+
<
15091535
Associated setting variables:
15101536
|g:netrw_gx| control how gx picks up the text under the cursor
15111537
|g:netrw_nogx| prevent gx map while editing
15121538
|g:netrw_suppress_gx_mesg| controls gx's suppression of browser messages
15131539

1540+
OPENING FILES AND LAUNCHING APPS *netrw-gx* *:Open* *:Launch* {{{2
1541+
1542+
Netrw determines which special handler by the following method:
1543+
1544+
* if |g:netrw_browsex_viewer| exists, then it will be used to attempt to
1545+
view files.
1546+
If the viewer you wish to use does not support handling of a remote URL
1547+
directory, set |g:netrw_browsex_support_remote| to 0.
1548+
* otherwise:
1549+
1550+
* for Windows : explorer.exe is used
1551+
* for Mac OS X : open is used.
1552+
* for Linux : xdg-open is used.
1553+
1554+
To open a path (or URL) <path> by the appropriate handler, type >
1555+
1556+
:Open <path>
1557+
<
1558+
No escaping, neither for the shell nor for Vim's command-line, is needed.
1559+
1560+
To launch a specific application <app> <args>, often <args> being <path> >
1561+
1562+
:Launch <app> <args>.
1563+
1564+
Since <args> can be arbitrarily complex, in particular contain many file
1565+
paths, the escaping is left to the user.
1566+
1567+
If you disabled the netrw plugin by setting g:loaded_netrwPlugin (see
1568+
|netrw-noload|), then you can use >
1569+
1570+
:call netrw#Launch('<app> <args>')
1571+
:call netrw#Open('<path>')
1572+
<
15141573
*netrw-curdir*
15151574
DELETING BOOKMARKS *netrw-mB* {{{2
15161575

0 commit comments

Comments
 (0)