docs/explorer.md
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:
nvim with a directoryConfiguring 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
}
}
}
}
}
The explorer provides powerful file operations with an intuitive selection-based workflow.
The most efficient way to move or copy multiple files:
<Tab> (works on multiple files)m to move selected files to the current directoryc to copy selected files to the current directoryExample 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:
m on a single file (no selection) → renames the filec on a single file (no selection) → prompts for new name to copy tor → rename current filed → delete current/selected filesAlternative workflow using yank and paste:
<Tab> or visual modey to yank file paths to registerp to paste (copies files from register)This works across different explorer instances and even after closing/reopening!
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<CR> or l → 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<leader>/ → Grep in current directory<c-t> → Open terminal in current directory<c-c> → Change tab directory to current directoryP → Toggle previewWhen git_status = true (default), files show git status indicators:
]g / [g → Jump to next/previous git changeWhen 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 warningYou can use visual mode (v or V) to select multiple files, then:
y → Yank selected file paths-- 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
}
}
}
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
}
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)