Created
April 26, 2024 11:23
-
-
Save mgedmin/690b2a9a1b470f7205c205b56d6dac40 to your computer and use it in GitHub Desktop.
Show/hide terminal by pressing F12 in Vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun! ToggleTerminal() | |
let terms = term_list() | |
if terms == [] " no terminals, open one | |
botright term | |
elseif bufwinnr(terms[0]) == -1 " terminal hidden, show it | |
exec 'botright sbuffer' terms[0] | |
else " terminal visible, hide it | |
exec bufwinnr(terms[0]) .. 'hide' | |
endif | |
endf | |
map <F12> <Cmd>call ToggleTerminal()<CR> | |
tmap <F12> <Cmd>call ToggleTerminal()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment