mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4mobile wallpaper 5mobile wallpaper 6
561 words
3 minutes
Netrw Cheatsheet

Startup#

You can enter Netrw when starting Vim or call it anytime within the editor.

CommandDescription
vim .Open Vim in the current directory
:ExExplore: Open directory in the current window (defaults to the current file’s directory)
:Ex <path>Open specified directory, e.g., :Ex ~/projects
:VexVertical Split: Open in vertical split (like a sidebar, recommended)
:Vex!Open in vertical split (on the right side)
:SexSplit: Open in horizontal split
:TexTab: Open directory in a new tab
:LexploreToggle: Toggle left directory tree (great for key mapping)

Display Mode#

The default Netrw interface is quite simple. You can adjust it to a modern tree view using the following keys.

KeyFunction
iToggle view mode (cycle through):
1. Thin (List)
2. Long (Detailed List)
3. Wide (Multi-column)
4. Tree (Recommended)
IToggle Banner: Show/Hide the help information at the top (hiding gives more view space)
ghToggle hidden files: Show/Hide files starting with .
sSort: Cycle through sorting methods (by name, time, size, etc.)

Navigation#

Core navigation operations when the cursor is within the Netrw window.

KeyFunction
EnterEnter directory / Open file
-Go up one directory (Core key)
uGo back to the previous directory in history
UGo forward to the next directory in history
%Create new file (enter filename and press Enter)
dCreate new directory (Make Directory)

File Manipulation#

Directly manage the file system within Netrw.

KeyFunction
%New file: Enter filename, press Enter to confirm
dNew directory: Enter directory name, press Enter to confirm
RRename: Rename the file or directory under the cursor
DDelete: Delete the file or directory under the cursor (confirmation required)
XExecute: Open file with the system’s default program (e.g., open .html in a browser)

Opening Files#

Decide how to open a file when your cursor is on it.

KeyFunction
EnterOpen in the current window (unless configured with browse_split)
oOpen in horizontal split
vOpen in vertical split
tOpen in a new tab
pPreview file - does not leave Netrw window
PEdit in Previous Window

Copy & Move#

Netrw’s copy/move logic is: first mark the Target directory, then mark the Source files, and finally execute.

Operation flow:

  1. Set Target Directory: Move the cursor to the directory where you want to place the files, press mt (Mark Target).

    • Tip: The top Banner will show Target: ...
  2. Select Files: Move to the files you want to operate on, press mf (Mark File) to mark them.

    • Tip: The marked filenames will become bold or change color; you can mark multiple files.
  3. Execute Command:

    • Press mc: Copy marked files to the target directory (Copy).
    • Press mm: Move marked files to the target directory (Move).
KeyFunction
mtMark current directory as Target
mfMark/Unmark file under the cursor
muUnmark all marked files
mcExecute Copy marked files to Target
mmExecute Move marked files to Target

Bookmarks#

Quickly jump to frequently used directories.

KeyFunction
mbSet bookmark: Add the current directory to the bookmark list
qbView bookmarks: List all bookmarks and history paths
gbGo to bookmark: Jump to the next bookmark location
mBDelete bookmark: Remove the bookmark under the cursor (use in qb list)

Remote Editing#

Netrw’s killer feature, supporting SCP, SFTP, FTP, and more. Vim automatically downloads files to /tmp and uploads them upon saving.

Syntax:

:e scp://user@host//path/to/file
NOTE

The double slashes // after the host indicate an absolute path from the root directory; a single slash / indicates a path relative to the user’s home directory.

Examples:

  • Edit remote file: :e scp://root@192.168.1.10://etc/nginx/nginx.conf
  • Browse remote directory: :Ex scp://user@myserver.com/projects/

Configuration#

See :h netrw-setup for detailed configuration options. Here are my commonly used settings:

-- ===========================
-- Netrw Config
-- ===========================
local g = vim.g
g.netrw_liststyle = 3 -- Use tree-style listing
g.netrw_keepdir = 0 -- Allow changing CWD
g.netrw_browse_split = 0 -- Open file in current tab
g.netrw_altv = 1 -- When splitting vertically, open the new window to the right
g.netrw_preview = 1 -- Enable file preview window
g.netrw_fastbrowse = 1 -- Enable fast browsing
g.netrw_localmovecmd = 'mv' -- Resolve deleting and renaming issues in tree style listing
Share

If this article helped you, please share it with others!

Netrw Cheatsheet
https://yur1ka.netlify.app/posts/25_12_05_netrw/
Author
FuFu
Published at
2025-12-05
License
Unlicensed

Some information may be outdated

Cover
Sample Song
Sample Artist
Cover
Sample Song
Sample Artist
0:00 / 0:00