feat: add rename with substitute command#3338
Open
Uanela wants to merge 2 commits into
Open
Conversation
v3ceban
approved these changes
Jun 16, 2026
v3ceban
left a comment
Collaborator
There was a problem hiding this comment.
I considered adding something like this in my initial implementation of bulk ops, but ended up not to due to complexities of renaming directories, nested structures, and converting files <-> dirs. If this only targets files I imagine it should be good.
It's missing the mappings to actually try it out, but the logic looks good to me. There are no regressions with existing bulk ops.
I'll leave organization questions for the core maintener to decide on.
Comment on lines
+539
to
+540
| local start_line = vim.fn.line(opts.use_native == true and "'<" or "v") | ||
| local end_line = vim.fn.line(opts.use_native == true and "'>" or ".") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation #3328
I found this feature on Oil and at least for me this was/is the main reason I use Oil, the first one was visual operations like copy/delete/cut and so on, but this one was missing, basically allowing :%s/old/new to change nodes names renaming and writing to disk.
Changes
1 - Added
M.bulk_renameintorename-file.lua2 - Added
optsintoM.renameto prevent notifications as it is used on a loop3 - Added
optstoget_visual_nodesto correctly allow using'<,'>when needed4 - (Not quite sure where to put yet or organize), Added an
autocmdfor watching ex commandsFeatures
1 -
:%s/old/newwill select or visible nodes and a simple prompt to rename (substitute) if yes they are written to disk2 -
:'<,'>s/old/newworks the same way but on the visual selected partConcerns
1 - Where and how should the new ex commands autocmd be devided?
2 - Should the autocmd of ex commands stay? or instead create at dedicated something like
NvimTreeSubsor whatever to put the tree into substitution mode? - first approach is more natural and expectedI am quite sure that there is a lot of work regarding code organization here, will just wait for your suggestions.