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

KeybindingCommandDescription
C-x dscimax.dired.openOpen dired (prompts for directory or uses workspace)
C-x 5 dscimax.dired.openOtherWindowOpen dired in a new window (prompts for directory)
scimax.dired.openCurrentOpen dired for current file's directory
scimax.dired.openWorkspaceOpen dired for workspace root

Navigation

Once in the dired panel, use these keys to navigate:

KeyAction
n or j or DownMove to next file
p or k or UpMove to previous file
RET or oOpen file/directory
^Navigate to parent directory
gRefresh directory listing
<Go to first entry
>Go to last entry

Marking Files

Mark files for batch operations:

KeyAction
mMark current file and move down
uUnmark current file and move down
UUnmark all files
tToggle all marks
dFlag file for deletion
% mMark files matching regex pattern
* eMark edited files (git)
* ?Mark untracked files (git)
* cMark files in conflict (git)
MMark 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):

KeyAction
DDelete marked/flagged files (moves to trash by default)
CCopy marked files (prompts for destination)
RRename/move marked files (prompts for destination)
+Create new directory
FOpen 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:

KeyAction
C-x v vNext 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 lCommits touching any of them; the picked commit opens as a multi-file diff
C-x v uDiscard all their changes, after one confirmation
C-x v iAdd a .gitignore pattern for each (directories get a trailing /)
C-x v gBlame 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).

Actions Menu (M-o or right-click)

Press M-o (Option+O on Mac), or right-click a row, to open a fuzzy picker of actions for that file. On . or .. the menu offers only the directory action.

ActionDescription
Enter DirectoryEnter the selected directory
Open in EditorOpen file in VS Code editor
Open in Finder/ExplorerReveal in system file manager
Copy PathCopy full path to clipboard
Copy FileCopy file to destination
Rename/MoveRename or move file
DeleteDelete file (with confirmation)
MarkMark file for batch operations
UnmarkRemove mark from file
Flag for DeletionFlag file for deletion
Open This Directory in Finder/ExplorerOpen the current directory in the OS
VC: Next Action, Diff, Log, ...Git commands on the marks (in a repository)

WDired Mode (Writable Dired)

WDired mode allows you to rename files by editing their names directly, like editing text:

KeyAction
C-x C-qEnter wdired mode (names become editable)
C-c C-cCommit renames
C-c C-kCancel and exit wdired mode

In wdired mode:

  1. Edit filenames directly in the listing

  2. Changes are highlighted

  3. Press C-c C-c to apply all renames at once

  4. Press C-c C-k to discard changes

Sorting and Filtering

KeyAction
sCycle 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

SettingDefaultDescription
scimax.dired.showGitStatustrueShow the git status column in a repository
scimax.dired.showHiddenfalseShow hidden files by default
scimax.dired.confirmDeletetrueShow 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