Skip to content

Commit

Permalink
feat: add TTerm command to open terminal in a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed Sep 28, 2018
1 parent 28d1899 commit 836f514
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 16 additions & 4 deletions plugin/split-term.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,23 @@ endf
" Opens a new terminal buffer, but instead of doing so using 'enew' (same
" window), it uses :vnew and :new instead. Usually, I want to open a new
" terminal and not replace my current buffer.
fun! s:openTerm(args, count, vertical)
let params = split(a:args)
fun! s:openSplitTerm(args, count, vertical)
let direction = s:force_vertical ? 1 : a:vertical

call s:openBuffer(a:count, direction)
call s:openTerm(a:args)
endf

" Opens a new terminal buffer, but instead of doing so using split buffer, it
" uses :tabnew instead.
fun! s:openTabTerm(args)
exe 'tabnew'
call s:openTerm(a:args)
endf

" Open a new terminal in the active buffer, while defining default mappings
" for this plugin.
fun! s:openTerm(args)
let prevShell = &shell
if exists('g:split_term_default_shell')
exe 'set shell =' . s:default_shell
Expand All @@ -75,5 +86,6 @@ fun! s:openTerm(args, count, vertical)
endif
endf

command! -count -nargs=* Term call s:openTerm(<q-args>, <count>, 0)
command! -count -nargs=* VTerm call s:openTerm(<q-args>, <count>, 1)
command! -count -nargs=* Term call s:openSplitTerm(<q-args>, <count>, 0)
command! -count -nargs=* VTerm call s:openSplitTerm(<q-args>, <count>, 1)
command! -nargs=* TTerm call s:openTabTerm(<q-args>)
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ extracting the files in your `~/.vim` or `~/.config/nvim` directory.

- **`:Term`** Opens a new terminal buffer using `:new` (splits horizontally)
- **`:VTerm`** Opens a new terminal buffer using `:vnew` (splits vertically)
- **`:TTerm`** Opens a new terminal buffer using `:tabnew` (new tab)

Both commands accept a `<count>` like their `:new`/`:vnew` counterparts. You
can prefix both commands with a number to specifiy the buffer height / width.
Both `:Term` and `:VTerm` commands accept a `<count>` like their `:new`/`:vnew`
counterparts. You can prefix both commands with a number to specifiy the buffer
height / width.

Similar to the original `:terminal`, both commands accepts any number of
arguments. It can be used to spawn a cmd and see the result, or even start a
Expand Down

0 comments on commit 836f514

Please sign in to comment.