[Terminal] How to change <esc> to jk for normal mode & mapping for toggling floating terminal #995
Unanswered
rbhanot4739
asked this question in
Q&A
Replies: 3 comments 2 replies
-
I have { "<C-t>", mode = { "n", "t", "i" }, function()
local ft = vim.bo.filetype
local ft_cmds = {python = "python", lua = "lua"}
print(ft)
Snacks.terminal.toggle(ft_cmds[ft])
end,
desc = "Toggle Terminal", }, To open the terminal and vim.api.nvim_create_autocmd("TermOpen", {
pattern = "*",
callback = function()
local term_title = vim.b.term_title
if term_title and term_title:match("lua") then
vim.keymap.set("t", "<C-t>", "<cmd>close<cr>", { buffer = true })
end
end,
}) To toggle the terminal |
Beta Was this translation helpful? Give feedback.
2 replies
-
I'm using autocmd to create keybinds for that specific terminal only because I use mutltiple terminals(one for lazygit, one for zsh). Otherwise the same keybind would close other kinds of terminals as well. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@maskudo this seems to work without the need of an autocmd {
"<M-/>",
mode = { "n", "t", "i" },
function()
local ft = vim.bo.filetype
local ft_cmds = { python = "ipython", lua = "lua" }
if ft == "snacks_terminal" then
vim.cmd("close")
else
Snacks.terminal.toggle(ft_cmds[ft], { interactive = false })
end
end,
desc = "Toggle terminal",
} And also I ended up doing |
Beta Was this translation helpful? Give feedback.
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to change the default mapping of double
<esc>
tojk
to go to normal mode in terminal without having to overwrite the entire key spec for it like below ?On the same note I was trying to create a mapping to a file-type-specific repl terminal, but I am not able to toggle it properly.
So pressing
<M-/>
opens a floating repl for me but when I press it again the it does not toggle the current floating repl instead it opens another snacks terminal window in bottom position and pressing<M-/>
2 more times actually closes the floating repl window.I think the reason for is that
ft
of the floating repl issnacks_terminal
but I can't figure out how to close that.Beta Was this translation helpful? Give feedback.
All reactions