Home

Awesome

⚠️ NOT MAINTAINED ANYMORE! ⚠️

🆕 ➡️ See new version written in lua: https://github.com/caenrique/buffer-term.nvim

Toggle terminal buffer or create new one if there is none. It keeps the shell session between toggles.

<p align="center"> <img src="https://i.imgur.com/vL96PcL.gif"> <p>

You have to set your own key bindings. For example:

nnoremap <silent> <C-z> :ToggleTerminal<Enter>
tnoremap <silent> <C-z> <C-\><C-n>:ToggleTerminal<Enter>

Commands

CommandDescription
:ToggleTerminalToggles a terminal which is the same shell instance regardless of where it is called
:ToggleTabTerminalToggles a tab specific terminal instance. It will have a different shell session for each tab
:ToggleWindowTerminalToggles a window specific terminal instance. It will have a different shell session for each window

Settings

SettingDescriptionDefault
g:preserve_alternate_bufferPreserve the alternate_buffer of the current window when opening and closing the terminal1
g:auto_start_insertenter insert mode automatically when given focus. Uses BufEnter event0
g:open_in_insert_modestart in insert mode when you open the terminal. Uses BufWinEnter event1

Instalation

Use your favourite plugin manager. For example, using Plug:

call plug#begin()
Plug 'caenrique/nvim-toggle-terminal'
call plug#end()

Other useful settings

Some extra setting that can be used in conjuction with this plugin for convenience:

Make your life easier by mapping ESC in terminal mode. And if you use fzf, this will not break the ESC behaviour:

tnoremap <expr> <Esc> (&filetype == "fzf") ? "<Esc>" : "<c-\><c-n>"

Use this to switch back and forth between files and terminal without the anoying No write since last change (add ! to override) message with unsaved changes:

set autowriteall

Use nvr to avoid nesting nvim in Terminal buffers. This should go in your .bashrc or similar:

nvim_wrapper() {
  NVIM=`which nvim`
  if test -z $NVIM_LISTEN_ADDRESS; then
      $NVIM $@
  else
    if test -z $@; then
        nvr -l -c new
    else
        nvr -l $@
    fi
  fi
}
alias nvim="nvim_wrapper"