Home Explore Blog CI



neovim

43th chunk of `runtime/pack/dist/opt/netrw/doc/netrw.txt`
9383a19db19b8d838c1d36f3f38db7ad3f2e49ff7707e94a0000000100000fa2
 |g:netrw_preview| first.

An interesting set of netrw settings is: >

	let g:netrw_preview   = 1
	let g:netrw_liststyle = 3
	let g:netrw_winsize   = 30

These will:

	1. Make vertical splitting the default for previewing files
	2. Make the default listing style "tree"
	3. When a vertical preview window is opened, the directory listing
	   will use only 30% of the columns available; the rest of the window
	   is used for the preview window.

	Related: if you like this idea, you may also find :Lexplore
	         (|netrw-:Lexplore|) or |g:netrw_chgwin| of interest

Also see: |g:netrw_chgwin| |netrw-P| |'previewwindow'| |CTRL-W_z| |:pclose|


PREVIOUS WINDOW					*netrw-P* *netrw-prvwin* {{{2

To edit a file or directory under the cursor in the previously used (last
accessed) window (see :he |CTRL-W_p|), press a "P".  If there's only one
window, then the one window will be horizontally split (by default).

If there's more than one window, the previous window will be re-used on
the selected file/directory.  If the previous window's associated buffer
has been modified, and there's only one window with that buffer, then
the user will be asked if they wish to save the buffer first (yes, no, or
cancel).

Related Actions |netrw-cr| |netrw-o| |netrw-t| |netrw-v|
Associated setting variables:
   |g:netrw_alto|    control above/below splitting
   |g:netrw_altv|    control right/left splitting
   |g:netrw_preview| control horizontal vs vertical splitting
   |g:netrw_winsize| control initial sizing

Also see: |g:netrw_chgwin| |netrw-p|


REFRESHING THE LISTING		*netrw-refresh* *netrw-ctrl-l* *netrw-ctrl_l* {{{2

To refresh either a local or remote directory listing, press ctrl-l (<c-l>) or
hit the <cr> when atop the ./ directory entry in the listing.  One may also
refresh a local directory by using ":e .".


REVERSING SORTING ORDER		*netrw-r* *netrw-reverse* {{{2

One may toggle between normal and reverse sorting order by pressing the
"r" key.

Related topics:              |netrw-s|
Associated setting variable: |g:netrw_sort_direction|


RENAMING FILES OR DIRECTORIES	*netrw-move* *netrw-rename* *netrw-R* {{{2

If there are no marked files: (see |netrw-mf|)

    Renaming files and directories involves moving the cursor to the
    file/directory to be moved (renamed) and pressing "R".  You will then be
    queried for what you want the file/directory to be renamed to.  You may
    select a range of lines with the "V" command (visual selection), and then
    press "R"; you will be queried for each file as to what you want it
    renamed to.

If there are marked files:  (see |netrw-mf|)

    Marked files will be renamed (moved).  You will be queried as above in
    order to specify where you want the file/directory to be moved.

    If you answer a renaming query with a "s/frompattern/topattern/", then
    subsequent files on the marked file list will be renamed by taking each
    name, applying that substitute, and renaming each file to the result.
    As an example : >

	mr  [query: reply with *.c]
	R   [query: reply with s/^\(.*\)\.c$/\1.cpp/]
<
    This example will mark all "*.c" files and then rename them to "*.cpp"
    files.  Netrw will protect you from overwriting local files without
    confirmation, but not remote ones.

    The ctrl-X character has special meaning for renaming files: >

	<c-x>      : a single ctrl-x tells netrw to ignore the portion of the response
	             lying between the last '/' and the ctrl-x.

	<c-x><c-x> : a pair of contiguous ctrl-x's tells netrw to ignore any
		     portion of the string preceding the double ctrl-x's.
<
    WARNING: ~

    Note that moving files is a dangerous operation; copies are safer.  That's
    because a "move" for remote files is actually a copy + delete -- and if
    the copy fails and the delete succeeds you may lose the file.
    Use at your own risk.

The *g:netrw_rename_cmd* variable is used to implement remote renaming.  By
default its value is: >

	ssh HOSTNAME mv
<
One may

Title: Netrw: Preview Window Settings, Previous Window, Refreshing, Sorting, and Renaming
Summary
This section covers various Netrw functionalities, including preview window settings for vertical splitting and tree-style listing. It details using the 'P' key to open files in the previously used window, refreshing directory listings with ctrl-l, reversing the sorting order with 'r', and renaming files/directories with 'R', including batch renaming with substitution patterns. It also discusses the potential risks of moving files and the usage of the g:netrw_rename_cmd variable.