vimtricks.wiki Concise Vim tricks, one at a time.

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

  • mfmark 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.
  • mtmark target: sets the directory under the cursor as the copy/move destination. The target path appears in the netrw banner.
  • mccopy marked files to target: copies all mf-marked files into the mt target directory.
  • mmmove marked files to target: moves (renames) them instead.
  • muunmark 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 :Lexplore to keep netrw in a persistent left-side panel while editing
  • mx runs a shell command on all marked files: mx chmod 644 makes them readable
  • To see currently marked files, check the netrw banner (toggle with I)

Next

How do I override Vim's case sensitivity for a single search without changing the global ignorecase setting?