Replies: 1 comment
|
Drop this in local function create_many()
local node = api.tree.get_node_under_cursor()
if not node then
return
end
local dir = node.type == "directory" and node.absolute_path
or vim.fn.fnamemodify(node.absolute_path, ":h")
vim.ui.input({ prompt = "Create files: " }, function(input)
if not input or input == "" then
return
end
for name in vim.gsplit(input, "%s+", { trimempty = true }) do
local path = vim.fs.joinpath(dir, name)
if name:match("/$") then
vim.fn.mkdir(path, "p")
else
vim.fn.mkdir(vim.fn.fnamemodify(path, ":h"), "p")
vim.fn.writefile({}, path, "b")
end
end
api.tree.reload()
end)
end
vim.keymap.set("n", "a", create_many, opts("Create files")) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
How can I create more than one file using
a? example you need to create three files in one folder test.cli test.log test.runAll reactions