A Neovim plugin for moving and renaming files from within Neovim.
:Move- Move files to new locations with buffer updates:Rename- Rename the current file with smart completion:Trash- Move files to trash or delete them:Remove- Permanently delete files:Mv- Alias for:Move:Rn- Alias for:Rename- Preserves cursor position and buffer state
- Updates all buffers pointing to moved files
- File and directory completion for arguments
- Smart completion for
:Renameusing filename segments
Using lazy.nvim:
return {
"opsaaaaa/movefile.nvim",
cmd = {"Move", "Rename", "Trash", "Remove", "Mv", "Rn"},
config = function()
require("movefile").setup({})
end
}Move the current file to a new location:
:Move ../notes/article.md
Move a specific file:
:Move old/name.md new/name.md
Move current file to a directory (keeps filename):
:Move ../archive/
Rename the current file (preserves extension):
:Rename new-filename
Rename and change extension:
:Rename new-filename.txt
The :Rename command provides smart completion by splitting the current
filename by separators (-, _, ., ). For a file named
20240116-project-notes.md, it would suggest:
20240116 -project -notes .md
This allows quick tab completion to build up the new filename.
Trash the current file (moves to trash folder):
:Trash
Trash a specific file:
:Trash old/file.md
Delete an empty directory:
:Trash empty-folder/
Permanently delete the current file:
:Remove
Permanently delete a specific file:
:Remove old/file.md
This command is equivalent to running :Trash with trash_soft_delete = true.
require("movefile").setup({
trash_folder = nil, -- Custom trash folder path
trash_soft_delete = false, -- Permanently delete instead of trash
})If trash_folder is not specified, the plugin searches for:
.Trashor.trashin the current directory~/.local/share/Trash
When trash_soft_delete is false (default), files are moved to:
<trash_folder>/files/<filename>- A
.trashinfometadata file is created at<trash_folder>/info/<filename>.trashinfo
When moving or renaming files:
- The buffer name is updated in place to preserve undo history and marks
- All other open buffers pointing to the same file are updated
- Cursor position is preserved after the operation