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

How do I mark multiple files in netrw and batch copy or move them to another directory?

Answer

mf mt mc

Explanation

Netrw, Vim's built-in file browser, supports a full marking system that lets you select multiple files and then perform bulk copy, move, or delete operations on all of them at once. The three key commands are mf (mark file), mt (mark target directory), and mc (mark copy).

How it works

  1. mf — Mark the file under the cursor. Repeat on each file you want to include. Marked files are highlighted.
  2. mr — Alternatively, mark files by a regex pattern (e.g., mr then .*\.py$ to mark all Python files at once).
  3. Navigate to the target directory where you want to copy the files.
  4. mt — Mark the current directory as the copy/move target.
  5. mc — Copy all marked files to the target directory. Use mm instead to move them.

Example

1. Open netrw: :Explore
2. Navigate to ~/src/
3. Press mf on file1.py
4. Press mf on file2.py
5. Navigate to ~/dest/ (or open it in the same window)
6. Press mt to set ~/dest/ as target
7. Press mc to copy both files

Tips

  • mu unmarks all files if you need to start over.
  • md deletes all marked files (use with care).
  • mx runs a shell command on all marked files: mx then type chmod +x.
  • You can mark files across different netrw windows and still use mt/mc to operate on them all at once.

Next

How do I open the directory containing the current file in netrw from within Vim?