Replies: 8 comments 7 replies
|
It's on the wiki: https://github.com/nvim-tree/nvim-tree.lua/wiki/Recipes#nerdtree-style-copy-file-to local function on_attach(bufnr)
...
local function move_file_to()
local node = api.tree.get_node_under_cursor()
local file_src = node['absolute_path']
local file_out = vim.fn.input("MOVE TO: ", file_src, "file")
local dir = vim.fn.fnamemodify(file_out, ":h")
vim.fn.system { 'mkdir', '-p', dir }
vim.fn.system { 'mv', file_src, file_out }
end
vim.keymap.set('n', 'X', move_file_to, opts('Move File To'))
end |
|
But this is still a copy (it doesn't remove the old location). This function does a vim.fn.system { 'cp', '-R', file_src, file_out }To move: vim.fn.system { 'mv', '-R', file_src, file_out }But the message I'm getting from this, is that the lack of a move is a design choice? |
|
removing the |
|
But |
|
yes you can rename the function. I've updated the snippet. |
|
Alright, thanks! Im wondering why this isn't in per default. |
|
Many thanks @joelpeapen |
|
One more question about this solution... If I rename a file I get a nice "in place" popup where I can type the name. Is it possible to use such a popup for this custom function as well @joelpeapen? |
Uh oh!
There was an error while loading. Please reload this page.
I saw that there is no "move" function on nvim-tree. Was that an oversight from me, or is there really no move?
Can this functionality be implemented utilising API?
It should be possible, as we can already cut and paste.
Is your feature request related to a problem? Please describe.
I wanted to move a file from
something/else/file.luatosomething/file.lua. You can achieve that by cutting and pasting, but why not have both in one step.Describe the solution you'd like
Just a move function. The window for moving it to somewhere else could look the same as the rename but also show the path that can be altered.
All reactions