Skip to content

Commit 21bf191

Browse files
committed
Update pi_netrw.{txt,jax}
1 parent 259c675 commit 21bf191

File tree

2 files changed

+157
-56
lines changed

2 files changed

+157
-56
lines changed

doc/pi_netrw.jax

Lines changed: 80 additions & 30 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 Oct 27
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
@@ -1434,42 +1434,92 @@ NETRW CLEAN *netrw-clean* *:NetrwClean* {{{2
14341434
どちらのコマンドも、本当に削除していいかどうかを確認するダイアログが最初に表示
14351435
されます。ファイルを削除する権限がない場合はエラーメッセージが表示されます。
14361436

1437-
*netrw-gx*
1437+
*netrw-gx* *Open* *Launch*
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> と入力します
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 を隠しリンクで動作させる関数 Netrw_get_URL_markdown()
1463+
" 次のような markdown URL [link text](http://ya.ru 'yandex search')
1464+
try
1465+
let save_view = winsaveview()
1466+
if searchpair('\[.\{-}\](', '', ')\zs', 'cbW', '', line('.')) > 0
1467+
return matchstr(getline('.')[col('.')-1:], '\[.\{-}\](\zs' .. g:netrw_regex_url .. '\ze\(\s\+.\{-}\)\?)')
1468+
endif
1469+
finally
1470+
call winrestview(save_view)
1471+
return ''
1472+
endtry
1473+
endfunction
1474+
1475+
function Netrw_get_URL_html()
1476+
" 次のような HTML URL <a href='http://www.python.org'>Python is here</a>
1477+
" <a href="http://www.python.org"/>
1478+
try
1479+
let save_view = winsaveview()
1480+
if searchpair('<a\s\+href=', '', '\%(</a>\|/>\)\zs', 'cbW', '', line('.')) > 0
1481+
return matchstr(getline('.')[col('.') - 1 : ],
1482+
\ 'href=["'.."'"..']\?\zs\S\{-}\ze["'.."'"..']\?/\?>')
1483+
endif
1484+
finally
1485+
call winrestview(save_view)
1486+
return ''
1487+
endtry
1488+
endfunction
1489+
<
1490+
1491+
ファイルパス以外に、カーソルの下のテキストが URL である場合もあります。Netrw
1492+
は、デフォルトで次の正規表現を使用して、カーソルの下のテキストが URL であるか
1493+
どうかを判断します。
1494+
>
1495+
g:netrw_regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}'
1496+
<
14431497

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

1448-
Netrw は次の方法で専用ハンドラを決定します:
1500+
* |g:netrw_browsex_viewer| が存在する場合、それを使用してファイルを表示しよ
1501+
うとします。便利な設定の例 (<.vimrc> に配置):
1502+
使用したいビューアがリモート URL ディレクトリの処理をサポートしていない場
1503+
合は、|g:netrw_browsex_support_remote| を 0 に設定します。
1504+
* 上記以外:
14491505

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

1453-
:let g:netrw_browsex_viewer= "kfmclient exec"
1454-
< or >
1455-
:let g:netrw_browsex_viewer= "xdg-open"
1456-
<
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 を押す方法でもよいです。
1510+
適切なハンドラでファイル <filepath> を開くには、以下を入力します
1511+
1512+
:Open <filepath>
1513+
1514+
シェルでも Vim のコマンドラインでもエスケープは必要ありません。
1515+
1516+
特定のアプリケーションを起動するには、<app> <args>、多くの場合、<args>
1517+
<filepath> です。
1518+
1519+
:Launch <app> <args>.
1520+
1521+
<args> は作為的に複雑になる可能性があり、特に多くのファイルパスが含まれる場合、
1522+
エスケープはユーザーに任されます。
14731523

14741524
関連設定:
14751525
|g:netrw_gx| gx がどのようにカーソル位置のテキストを取得するか制御

en/pi_netrw.txt

Lines changed: 77 additions & 26 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 Oct 27
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
@@ -1469,42 +1469,93 @@ With either form of the command, netrw will first ask for confirmation
14691469
that the removal is in fact what you want to do. If netrw doesn't have
14701470
permission to remove a file, it will issue an error message.
14711471

1472-
*netrw-gx*
1472+
*netrw-gx* *Open* *Launch*
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>
14821483

1483-
Netrw determines which special handler by the following method:
1484+
One may also use visual mode (see |visual-start|) to select the text that 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
1487+
|g:netrw_gx| variable (options include "<cword>", "<cWORD>"). Note that
1488+
expand("<cfile>") depends on the |'isfname'| setting. Alternatively, one may
1489+
select the text to be used by gx by making a visual selection (see
1490+
|visual-block|) and then pressing gx.
14841491

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>): >
1492+
The selection function can be adapted for each filetype by adding a function
1493+
Netrw_get_URL_<filetype>, where <filetype> is given by &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+
function Netrw_get_URL_markdown()
1500+
" markdown URL such as [link text](http://ya.ru 'yandex search')
1501+
try
1502+
let save_view = winsaveview()
1503+
if searchpair('\[.\{-}\](', '', ')\zs', 'cbW', '', line('.')) > 0
1504+
return matchstr(getline('.')[col('.')-1:], '\[.\{-}\](\zs' .. g:netrw_regex_url .. '\ze\(\s\+.\{-}\)\?)')
1505+
endif
1506+
finally
1507+
call winrestview(save_view)
1508+
return ''
1509+
endtry
1510+
endfunction
1511+
1512+
function Netrw_get_URL_html()
1513+
" HTML URL such as <a href='http://www.python.org'>Python is here</a>
1514+
" <a href="http://www.python.org"/>
1515+
try
1516+
let save_view = winsaveview()
1517+
if searchpair('<a\s\+href=', '', '\%(</a>\|/>\)\zs', 'cbW', '', line('.')) > 0
1518+
return matchstr(getline('.')[col('.') - 1 : ],
1519+
\ 'href=["'.."'"..']\?\zs\S\{-}\ze["'.."'"..']\?/\?>')
1520+
endif
1521+
finally
1522+
call winrestview(save_view)
1523+
return ''
1524+
endtry
1525+
endfunction
1526+
<
14871527

1488-
:let g:netrw_browsex_viewer= "kfmclient exec"
1489-
< or >
1490-
:let g:netrw_browsex_viewer= "xdg-open"
1528+
Other than a file path, the text under the cursor may be a URL. Netrw uses
1529+
by default the following regular expression to determine if the text under the
1530+
cursor is a URL:
1531+
>
1532+
g:netrw_regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}'
14911533
<
1534+
1535+
Netrw determines which special handler by the following method:
1536+
1537+
* if |g:netrw_browsex_viewer| exists, then it will be used to attempt to
1538+
view files. Examples of useful settings (place into your <.vimrc>):
14921539
If the viewer you wish to use does not support handling of a remote URL
14931540
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.
1541+
* otherwise:
14981542

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).
1501-
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
1504-
|g:netrw_gx| variable (options include "<cword>", "<cWORD>"). Note that
1505-
expand("<cfile>") depends on the |'isfname'| setting. Alternatively, one may
1506-
select the text to be used by gx by making a visual selection (see
1507-
|visual-block|) and then pressing gx.
1543+
* for Windows : explorer.exe is used
1544+
* for Mac OS X : open is used.
1545+
* for Linux : xdg-open is used.
1546+
1547+
To open a file <filepath> by the appropriate handler, type
1548+
1549+
:Open <filepath>
1550+
1551+
No escaping, neither for the shell, nor for Vim's command-line is needed.
1552+
1553+
To launch a specific application <app> <args>, often <args> being <filepath>,
1554+
1555+
:Launch <app> <args>.
1556+
1557+
Since <args> can be arbitrarily complex, in particular contain many file
1558+
paths, the escaping is left to the user.
15081559

15091560
Associated setting variables:
15101561
|g:netrw_gx| control how gx picks up the text under the cursor

0 commit comments

Comments
 (0)