Skip to content

Instantly share code, notes, and snippets.

@char101
Created October 3, 2021 06:20
Show Gist options
  • Save char101/38c5a0e826baca3d44fdc68264cc1123 to your computer and use it in GitHub Desktop.
Save char101/38c5a0e826baca3d44fdc68264cc1123 to your computer and use it in GitHub Desktop.
[vim] switch to existing terminal window
func s:Term()
let terms = term_list()
if len(terms) > 0
let winid = win_findbuf(terms[0])
let winnr = win_id2tabwin(winid[0])
exe 'tabnext '.winnr[0]
exe winnr[1].'wincmd w'
else
tab term
endif
endf
command Term call s:Term()
nnoremap <silent> <Leader>tt :Term<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment