Startup
You can enter Netrw when starting Vim or call it anytime within the editor.
| Command | Description |
|---|---|
vim . | Open Vim in the current directory |
:Ex | Explore: Open directory in the current window (defaults to the current file’s directory) |
:Ex <path> | Open specified directory, e.g., :Ex ~/projects |
:Vex | Vertical Split: Open in vertical split (like a sidebar, recommended) |
:Vex! | Open in vertical split (on the right side) |
:Sex | Split: Open in horizontal split |
:Tex | Tab: Open directory in a new tab |
:Lexplore | Toggle: 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.
| Key | Function |
|---|---|
i | Toggle view mode (cycle through): 1. Thin (List) 2. Long (Detailed List) 3. Wide (Multi-column) 4. Tree (Recommended) |
I | Toggle Banner: Show/Hide the help information at the top (hiding gives more view space) |
gh | Toggle hidden files: Show/Hide files starting with . |
s | Sort: Cycle through sorting methods (by name, time, size, etc.) |
Navigation
Core navigation operations when the cursor is within the Netrw window.
| Key | Function |
|---|---|
Enter | Enter directory / Open file |
- | Go up one directory (Core key) |
u | Go back to the previous directory in history |
U | Go forward to the next directory in history |
% | Create new file (enter filename and press Enter) |
d | Create new directory (Make Directory) |
File Manipulation
Directly manage the file system within Netrw.
| Key | Function |
|---|---|
% | New file: Enter filename, press Enter to confirm |
d | New directory: Enter directory name, press Enter to confirm |
R | Rename: Rename the file or directory under the cursor |
D | Delete: Delete the file or directory under the cursor (confirmation required) |
X | Execute: 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.
| Key | Function |
|---|---|
Enter | Open in the current window (unless configured with browse_split) |
o | Open in horizontal split |
v | Open in vertical split |
t | Open in a new tab |
p | Preview file - does not leave Netrw window |
P | Edit 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:
-
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: ...
- Tip: The top Banner will show
-
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.
-
Execute Command:
- Press
mc: Copy marked files to the target directory (Copy). - Press
mm: Move marked files to the target directory (Move).
- Press
| Key | Function |
|---|---|
mt | Mark current directory as Target |
mf | Mark/Unmark file under the cursor |
mu | Unmark all marked files |
mc | Execute Copy marked files to Target |
mm | Execute Move marked files to Target |
Bookmarks
Quickly jump to frequently used directories.
| Key | Function |
|---|---|
mb | Set bookmark: Add the current directory to the bookmark list |
qb | View bookmarks: List all bookmarks and history paths |
gb | Go to bookmark: Jump to the next bookmark location |
mB | Delete 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/fileNOTEThe 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 listingg.netrw_keepdir = 0 -- Allow changing CWDg.netrw_browse_split = 0 -- Open file in current tabg.netrw_altv = 1 -- When splitting vertically, open the new window to the rightg.netrw_preview = 1 -- Enable file preview windowg.netrw_fastbrowse = 1 -- Enable fast browsingg.netrw_localmovecmd = 'mv' -- Resolve deleting and renaming issues in tree style listingSome information may be outdated











