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
mf— Mark the file under the cursor. Repeat on each file you want to include. Marked files are highlighted.mr— Alternatively, mark files by a regex pattern (e.g.,mrthen.*\.py$to mark all Python files at once).- Navigate to the target directory where you want to copy the files.
mt— Mark the current directory as the copy/move target.mc— Copy all marked files to the target directory. Usemminstead 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
muunmarks all files if you need to start over.mddeletes all marked files (use with care).mxruns a shell command on all marked files:mxthen typechmod +x.- You can mark files across different netrw windows and still use
mt/mcto operate on them all at once.