How do I copy files to a target directory using netrw's marking system?
Answer
mt and mc in netrw
Explanation
Netrw, Vim's built-in file browser, has a full file-management workflow driven by marks. You can mark multiple files with mf, designate a target directory with mt, and then copy (mc) or move (mm) all marked files to the target — without leaving Vim or touching a shell.
How it works
mf— mark file: toggles a mark on the file under the cursor. Marked files are highlighted. You can mark as many as you like across multiple netrw windows.mt— mark target: sets the directory under the cursor as the copy/move destination. The target path appears in the netrw banner.mc— copy marked files to target: copies allmf-marked files into themttarget directory.mm— move marked files to target: moves (renames) them instead.mu— unmark all: clears all marks when you're done.
Example
Copy report.md and data.csv from ~/drafts/ to ~/published/:
1. :Explore ~/drafts/ ← open netrw in drafts
2. mf on report.md ← mark first file
3. mf on data.csv ← mark second file
4. :Explore ~/published/ ← open netrw in target
5. mt ← set ~/published/ as target
6. mc ← copy both files here
Tips
- You can mark files in one netrw split and set the target in another split — they share marks across windows in the same Vim session
- Use
:Lexploreto keep netrw in a persistent left-side panel while editing mxruns a shell command on all marked files:mx chmod 644makes them readable- To see currently marked files, check the netrw banner (toggle with
I)