Comments (2)
I currently get around this with the following code:
local function get_term_index(current_id, terms)
local idx
for i, v in ipairs(terms) do
if v.id == current_id then
idx = i
end
end
return idx
end
local function go_prev_term()
local current_id = vim.b.toggle_number
if current_id == nil then
return
end
local terms = require("toggleterm.terminal").get_all(true)
local prev_index
local index = get_term_index(current_id, terms)
if index > 1 then
prev_index = index - 1
else
prev_index = #terms
end
require("toggleterm").toggle(terms[index].id)
require("toggleterm").toggle(terms[prev_index].id)
end
local function go_next_term()
local current_id = vim.b.toggle_number
if current_id == nil then
return
end
local terms = require("toggleterm.terminal").get_all(true)
local next_index
local index = get_term_index(current_id, terms)
if index == #terms then
next_index = 1
else
next_index = index + 1
end
require("toggleterm").toggle(terms[index].id)
require("toggleterm").toggle(terms[next_index].id)
end
vim.keymap.set({ "n", "t" }, "<F9>", "<cmd>ToggleTerm<cr>", { desc = "Toggle term" })
vim.keymap.set({ "n", "t" }, "<F8>", function()
go_next_term()
end, { desc = "Toggle term" })
vim.keymap.set({ "n", "t" }, "<F7>", function()
go_prev_term()
end, { desc = "Toggle term" })
from toggleterm.nvim.
I would love this as well. It's how I was using floaterm, but toggleterm seems to offer much more than floaterm.
from toggleterm.nvim.
Related Issues (20)
- [Feature] Add :ToggleTermSendCurrentLineOrSelection HOT 1
- [BUG] Nvim sometimes freezes when toggleterm is in background as if throttling HOT 3
- [Feature] Register arbitrary term window for TT management HOT 6
- [BUG] is there a way to paste in toggle term? HOT 1
- [Question] Normal key maps in term HOT 2
- [BUG] Remapping escape to <C-\><C-n> doesn't work HOT 6
- [help] How to hide/customize bottom bar in terminal HOT 2
- [BUG] Reverse range in character class
- End of line not interpreted in powershell on linux HOT 2
- [Feature Request] Support Vim Sessions
- Toggleterm adds cursor line number when using count modifier to set the id
- Question. Reuse terminal to execute new command
- [BUG] open_mapping keybinding only works after `:ToggleTerm` has been called before HOT 4
- [FETURE] How do I re-run a previous command? HOT 1
- [BUG] TermSelect doesn't show anything HOT 1
- [FEATURE] Different shading factor for bright/dark theme
- [BUG] set `dir = git_dir` will not make toggleterm try and derive the git repo directory
- [BUG] toggleterm changing terminal width strangely with `signcolumn = "yes"`
- Q: How to make toggleterm not capture certain inputs HOT 1
- [BUG] toggle term does not respect venv HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toggleterm.nvim.