rm.nvim
November 10, 2025 ยท View on GitHub
A modern Neovim plugin for safely deleting files with trash/recycle bin support.
Features
- ๐๏ธ Custom Commands: Use any UNIX command for file deletion
- โ Confirmation Prompts: Configurable confirmation before deletion
- ๐ง Highly Configurable: Customize behavior to match your workflow
- ๐ฆ Buffer Cleanup: Automatically closes deleted file buffers
- ๐ Modern Lua API: Built with Neovim's latest Lua features
Installation
lazy.nvim
{
'babarot/rm.nvim',
opts = {
-- Optional: configure here
-- command = 'gomi',
},
}
Or with lazy loading:
{
'babarot/rm.nvim',
cmd = 'Rm', -- Load when :Rm is executed
opts = {
command = 'gomi',
},
}
packer.nvim
use {
'babarot/rm.nvim',
config = function()
require('rm').setup()
end,
}
vim-plug
Plug 'babarot/rm.nvim'
lua << EOF
require('rm').setup()
EOF
Usage
Quick Start
First, call setup() in your Neovim configuration:
require('rm').setup()
This creates the :Rm command by default.
Commands
:Rm- Delete current file with confirmation prompt:Rm!- Delete current file without confirmation
Note: Commands are only created after calling setup(). You can customize the command name or disable it entirely (see Configuration section).
Lua API
-- Delete current file
require('rm').delete_current_file({ bang = false })
-- Delete multiple files
require('rm').delete_files({ 'file1.txt', 'file2.txt' }, { bang = false })
-- Get current configuration
local config = require('rm').get_config()
Configuration
Default configuration:
require('rm').setup({
-- Custom deletion command
-- If {file} placeholder is not present, file path is appended at the end
-- Examples:
-- 'gomi' -> 'gomi /path/to/file'
-- 'gomi {file}' -> 'gomi /path/to/file'
-- 'mv {file} ~/.Trash/' -> 'mv /path/to/file ~/.Trash/'
-- If nil, uses os.remove() for permanent deletion
command = nil,
-- Confirm before deletion by default
confirm = true,
-- Show notification after successful deletion
notify = true,
-- Notification level
notify_level = vim.log.levels.INFO,
-- Save file before deletion
save_before_delete = true,
-- Command creation settings
create_commands = true, -- Set to false to disable automatic command creation
-- Command names (only used when create_commands is true)
commands = {
delete = "Rm", -- Name of the delete command
},
})
Example Configurations
Use gomi trash tool
require('rm').setup({
command = 'gomi',
})
Use trash-cli (Linux)
require('rm').setup({
command = 'trash',
})
Use GNOME gio trash
require('rm').setup({
command = 'gio trash',
})
Move to Trash folder (macOS)
require('rm').setup({
command = 'mv {file} ~/.Trash/',
})
Always skip confirmation
require('rm').setup({
command = 'gomi',
confirm = false,
})
Silent deletion
require('rm').setup({
notify = false,
})
Custom command name
require('rm').setup({
commands = {
delete = "Delete", -- Use :Delete instead of :Rm
},
})
Disable automatic commands (Lua API only)
require('rm').setup({
command = 'gomi',
create_commands = false, -- No :Rm command created
})
-- Use Lua API directly
vim.keymap.set('n', '<leader>fd', function()
require('rm').delete_current_file({ bang = false })
end, { desc = 'Delete current file' })
Recommended Trash Tools
You can use any command-line trash tool with this plugin:
By default (without configuration), the plugin uses os.remove() for permanent deletion.
Keybindings
You can set up custom keybindings for quick file deletion:
-- Delete current file with confirmation
vim.keymap.set('n', '<leader>fd', ':Rm<CR>', { desc = 'Delete current file' })
-- Delete current file without confirmation
vim.keymap.set('n', '<leader>fD', ':Rm!<CR>', { desc = 'Delete current file (no confirm)' })
-- Or use Lua API directly
vim.keymap.set('n', '<leader>fd', function()
require('rm').delete_current_file({ bang = false })
end, { desc = 'Delete current file' })
Related Projects
License
MIT
Author
babarot