Dired - Directory Editor
Dired (Directory Editor) provides Emacs-style file management in VS Code. It displays directory listings in a webview panel where you can navigate, mark files, and perform bulk operations using familiar Emacs keybindings.
Opening Dired
| Keybinding | Command | Description |
|---|---|---|
C-x d | scimax.dired.open | Open dired (prompts for directory or uses workspace) |
C-x 5 d | scimax.dired.openOtherWindow | Open dired in a new window (prompts for directory) |
scimax.dired.openCurrent | Open dired for current file's directory | |
scimax.dired.openWorkspace | Open dired for workspace root |
Marking Files
Mark files for batch operations:
| Key | Action |
|---|---|
m | Mark current file and move down |
u | Unmark current file and move down |
U | Unmark all files |
t | Toggle all marks |
d | Flag file for deletion |
% m | Mark files matching regex pattern |
* e | Mark edited files (git) |
* ? | Mark untracked files (git) |
* c | Mark files in conflict (git) |
M | Mark files in this file's git state |
Marked files appear with * indicator. Flagged files (for deletion) appear with D indicator.
File Operations
Operate on marked files (or current file if none marked):
| Key | Action |
|---|---|
D | Delete marked/flagged files (moves to trash by default) |
C | Copy marked files (prompts for destination) |
R | Rename/move marked files (prompts for destination) |
+ | Create new directory |
F | Open the current directory in Finder/Explorer |
Git Status and Version Control
Inside a git repository, dired shows a git status column: edited,
edited, staged, edited, part staged, added, staged, removed,
renamed, staged, untracked, ignored or conflict. Up-to-date files show
nothing. A directory shows the strongest state of the files below it
(conflict, then edited, then untracked), so you can see where the changes are.
Turn the column off with scimax.dired.showGitStatus.
The C-x v commands act on the marked files, or on the file at point when
nothing is marked:
| Key | Action |
|---|---|
C-x v v | Next action on the whole set (register, commit, resolve), see below |
C-x v = | One multi-file diff of all their changes against HEAD |
C-x v l | Commits touching any of them; the picked commit opens as a multi-file diff |
C-x v u | Discard all their changes, after one confirmation |
C-x v i | Add a .gitignore pattern for each (directories get a trailing /) |
C-x v g | Blame the first file |
C-x v v on several files works like Emacs vc-next-action on a fileset:
every changed file must be in the same state. Untracked files are registered,
edited files are committed in one commit (git commit -- files, so other
staged files stay staged), conflicted files are marked resolved. With files
in different states, it names the files in each state; mark one group with
* e, * ? or * c and try again. Up-to-date files in the set are left out.
The listing refreshes after each command and keeps your marks. M-o also
offers these commands, plus Stage / Unstage. To see every changed file in the
repository in one list, use C-x v d (see Version Control).
WDired Mode (Writable Dired)
WDired mode allows you to rename files by editing their names directly, like editing text:
| Key | Action |
|---|---|
C-x C-q | Enter wdired mode (names become editable) |
C-c C-c | Commit renames |
C-c C-k | Cancel and exit wdired mode |
In wdired mode:
Edit filenames directly in the listing
Changes are highlighted
Press
C-c C-cto apply all renames at oncePress
C-c C-kto discard changes
Sorting and Filtering
| Key | Action |
|---|---|
s | Cycle sort field (name, size, date, extension) |
. | Toggle showing hidden files (dotfiles) |
/ | Set filter pattern (regex) |
Display Format
Each line shows:
drwxr-xr-x 4096 2024-01-15 10:30 Documents/ -rw-r--r-- 1234 2024-01-14 09:15 file.txt lrwxrwxrwx 12 2024-01-13 08:00 link -> target
First column: file permissions (d=directory, l=symlink, -=file)
Second column: file size
Third column: modification date/time
Fourth column: git status (only inside a git repository)
Last column: filename (directories end with /)
Configuration
| Setting | Default | Description |
|---|---|---|
scimax.dired.showGitStatus | true | Show the git status column in a repository |
scimax.dired.showHidden | false | Show hidden files by default |
scimax.dired.confirmDelete | true | Show confirmation before deleting |
scimax.dired.defaultSort | "name" | Default sort field (name, size, mtime, extension) |
Security
Dired includes security protections:
Path traversal prevention (no
..in filenames)Filename validation (no path separators in names)
Delete operations use system trash by default
Regex patterns are validated to prevent ReDoS attacks