nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

Rename before extension

Open sarmong opened this issue 3 years ago • 5 comments

Most of the time, when you rename a file, you don't want to change the extension, you just want to change the name of a file.

Therefore, it will be rather useful to add a new action, that will put the cursor directly before the file extension.

File browsers such as ranger or lf can be configured to have this feature (they also have the command prompt at the bottom as vim)

sarmong avatar Apr 11 '22 07:04 sarmong

go for it :)

kyazdani42 avatar Apr 12 '22 18:04 kyazdani42

Any tips? I don't really know where to start, that's why opened an issue;)

sarmong avatar Apr 12 '22 19:04 sarmong

go to the rename-file.lua and make a bit of an abstraction to rename either from filename or something else i suppose :)

kyazdani42 avatar Apr 12 '22 20:04 kyazdani42

Hm, I don't think it is possible with the current implementation of vim.ui.input as theit allows to provide default value and callback function, and there is really nowhere to move the cursor

sarmong avatar Apr 19 '22 19:04 sarmong

hum this look weird indeed, could you maybe just remove the whole name and saving the extension, call input without the name, then pasting the extension ? Not sure how to achieve that exactly but i believe it should be possible.

kyazdani42 avatar Apr 21 '22 18:04 kyazdani42

I've created a PR for this, feedback welcome. I've created new action "relative_rename" that changes the base name of the file - without changing directory or extension. This is what I tend to want to do from nvimtree most of the time. I use another extension to move files.

ianhomer avatar Nov 30 '22 15:11 ianhomer