Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function! TerminalTab()
- " find evey terminal buffer
- let b = filter(range(1, bufnr('$')),
- 'getbufvar(v:val, "&buftype", "ERROR") == "terminal"')
- " if no terminal buffers are available
- if len(b) == 0
- tabnew
- terminal
- else
- " we only care for the first terminal buffer
- let b = b[0]
- let bb = win_findbuf(b)
- " if there is no window in any tab that contains a terminal
- if len(bb) == 0
- tabnew
- buffer b
- else
- " again we only care for the first match
- let bb = win_id2tabwin(bb[0])
- exe 'tabnext'.bb[0]
- exe bb[1].'wincmd w'
- endif
- endif
- " we open a terminal to do something
- startinsert
- endfunc
- nmap <silent> <leader>s :call TerminalTab()<cr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement