|
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 |
2 | 2 |
|
3 | 3 | ------------------------------------------------
|
4 | 4 | NETRW REFERENCE MANUAL by Charles E. Campbell
|
|
8 | 8 |
|
9 | 9 | Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
|
10 | 10 | 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 |
12 | 12 | syntax/netrw.vim. Like anything else that's free, netrw.vim and its
|
13 | 13 | associated files are provided *as is* and comes with no warranty of
|
14 | 14 | any kind, either expressed or implied. No guarantees of
|
@@ -54,9 +54,10 @@ Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
|
54 | 54 | Browsing With A Horizontally Split Window...........|netrw-o|
|
55 | 55 | Browsing With A New Tab.............................|netrw-t|
|
56 | 56 | 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| |
59 | 58 | Changing To A Bookmarked Directory..................|netrw-gb|
|
| 59 | + Quick hide/unhide of dot-files......................|netrw-gh| |
| 60 | + Changing local-only File Permission.................|netrw-gp| |
60 | 61 | Changing To A Predecessor Directory.................|netrw-u|
|
61 | 62 | Changing To A Successor Directory...................|netrw-U|
|
62 | 63 | Customizing Browsing With A Special Handler.........|netrw-x|
|
@@ -1469,48 +1470,106 @@ With either form of the command, netrw will first ask for confirmation
|
1469 | 1470 | that the removal is in fact what you want to do. If netrw doesn't have
|
1470 | 1471 | permission to remove a file, it will issue an error message.
|
1471 | 1472 |
|
1472 |
| - *netrw-gx* |
1473 | 1473 | CUSTOMIZING BROWSING WITH A SPECIAL HANDLER *netrw-x* *netrw-handler* {{{2
|
1474 | 1474 |
|
1475 | 1475 | Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are
|
1476 | 1476 | 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: |
1478 | 1478 |
|
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. |
1482 | 1483 |
|
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). |
1501 | 1484 | 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 |
1504 | 1487 | |g:netrw_gx| variable (options include "<cword>", "<cWORD>"). Note that
|
1505 | 1488 | expand("<cfile>") depends on the |'isfname'| setting. Alternatively, one may
|
1506 | 1489 | select the text to be used by gx by making a visual selection (see
|
1507 | 1490 | |visual-block|) and then pressing gx.
|
1508 | 1491 |
|
| 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 | +< |
1509 | 1535 | Associated setting variables:
|
1510 | 1536 | |g:netrw_gx| control how gx picks up the text under the cursor
|
1511 | 1537 | |g:netrw_nogx| prevent gx map while editing
|
1512 | 1538 | |g:netrw_suppress_gx_mesg| controls gx's suppression of browser messages
|
1513 | 1539 |
|
| 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 | +< |
1514 | 1573 | *netrw-curdir*
|
1515 | 1574 | DELETING BOOKMARKS *netrw-mB* {{{2
|
1516 | 1575 |
|
|
0 commit comments