picker.command_history
: editing a command before executing it
#929
-
When using snacks to execute some command from the command history with |
Beta Was this translation helpful? Give feedback.
Answered by
Kailian-Jacy
Feb 13, 2025
Replies: 1 comment
-
Works for me: command_history = {
confirm = "modify",
actions = {
execute_without_modification = function (_, item)
local cmd;
if vim.fn.mode() == "i" then
cmd = "<esc>:" .. item.cmd
elseif vim.fn.mode() == "n" then
cmd = ":" .. item.cmd
end
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(cmd .. "<cr>", true, false, true), "n", false)
end,
modify = function (_, item)
local cmd;
if vim.fn.mode() == "i" then
cmd = "<esc>:" .. item.cmd
elseif vim.fn.mode() == "n" then
cmd = ":" .. item.cmd
end
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(cmd, true, false, true), "n", false)
end
},
win = {
input = {
keys = {
["<C-CR>"] = { "execute_without_modification", mode = {"n", "i"} },
["<D-CR>"] = { "execute_without_modification", mode = {"n", "i"} }
}
},
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ccidral
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works for me: