๐ฟ explorer
October 25, 2025 ยท View on GitHub
A file explorer for snacks. This is actually a picker in disguise.
This module provide a shortcut to open the explorer picker and a setup function to replace netrw with the explorer.
When the explorer and replace_netrw is enabled, the explorer will be opened:
- when you start
nvimwith a directory - when you open a directory in vim
Configuring the explorer picker is done with the picker options.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
explorer = {
-- your explorer configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
picker = {
sources = {
explorer = {
-- your explorer picker configuration comes here
-- or leave it empty to use the default settings
}
}
}
}
}
๐ Usage
File Operations
The explorer provides powerful file operations with an intuitive selection-based workflow.
Moving and Copying Files
The most efficient way to move or copy multiple files:
- Select files with
<Tab>(works on multiple files) - Navigate to the target directory
- Execute the operation:
- Press
mto move selected files to the current directory - Press
cto copy selected files to the current directory
- Press
Example workflow:
1. Navigate to source files
2. Press <Tab> on file1.txt
3. Press <Tab> on file2.txt (both now selected)
4. Navigate to target directory
5. Press 'm' โ files are moved!
Single file operations:
mon a single file (no selection) โ renames the filecon a single file (no selection) โ prompts for new name to copy torโ rename current filedโ delete current/selected files
Copy/Paste with Registers
Alternative workflow using yank and paste:
- Select files with
<Tab>or visual mode - Press
yto yank file paths to register - Navigate to target directory
- Press
pto paste (copies files from register)
This works across different explorer instances and even after closing/reopening!
Other File Operations
aโ Add new file or directory (directories end with/)dโ Delete files (uses system trash if available, see:checkhealth snacks)oโ Open file with system applicationuโ Update/refresh the file tree
Navigation
<CR>orlโ Open file or toggle directoryhโ Close directory<BS>โ Go up one directory.โ Focus on current directory (set as cwd)Hโ Toggle hidden filesIโ Toggle ignored files (from gitignore)Zโ Close all directories
Quick Actions
<leader>/โ Grep in current directory<c-t>โ Open terminal in current directory<c-c>โ Change tab directory to current directoryPโ Toggle preview
Git Integration
When git_status = true (default), files show git status indicators:
]g/[gโ Jump to next/previous git change- Directories show aggregate status of contained files
Diagnostics
When diagnostics = true (default), files show diagnostic indicators:
]d/[dโ Jump to next/previous diagnostic]e/[eโ Jump to next/previous error]w/[wโ Jump to next/previous warning
Visual Mode
You can use visual mode (v or V) to select multiple files, then:
yโ Yank selected file paths- Any other operation works on visual selection
๐ฆ Setup
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
explorer = {
-- your explorer configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
}
โ๏ธ Config
These are just the general explorer settings.
To configure the explorer picker, see snacks.picker.explorer.Config
---@class snacks.explorer.Config
{
replace_netrw = true, -- Replace netrw with the snacks explorer
trash = true, -- Use the system trash when deleting files
}
๐ฆ Module
Snacks.explorer()
---@type fun(opts?: snacks.picker.explorer.Config): snacks.Picker
Snacks.explorer()
Snacks.explorer.health()
Snacks.explorer.health()
Snacks.explorer.open()
Shortcut to open the explorer picker
---@param opts? snacks.picker.explorer.Config|{}
Snacks.explorer.open(opts)
Snacks.explorer.reveal()
Reveals the given file/buffer or the current buffer in the explorer
---@param opts? {file?:string, buf?:number}
Snacks.explorer.reveal(opts)