Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/caenrique/nvim-toggle-terminal

NeoVim plugin that toggles a terminal buffer in the current window maintaining the same shell instance
https://github.com/caenrique/nvim-toggle-terminal

neovim nvim nvim-plugin vim vim-plugin vimscript

Last synced: 8 days ago
JSON representation

NeoVim plugin that toggles a terminal buffer in the current window maintaining the same shell instance

Awesome Lists containing this project

README

        

⚠️ 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.



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

```vim
nnoremap :ToggleTerminal
tnoremap :ToggleTerminal
```

## Commands

| Command | Description |
|-----------------------|-----------------------------------------------------------------------------------------------------|
| :ToggleTerminal | Toggles a terminal which is the same shell instance regardless of where it is called |
| :ToggleTabTerminal | Toggles a tab specific terminal instance. It will have a different shell session for each tab |
| :ToggleWindowTerminal | Toggles a window specific terminal instance. It will have a different shell session for each window |

## Settings

| Setting | Description | Default |
|-----------------------------|-------------------------------------------------------------------------------------------|---------|
| g:preserve_alternate_buffer | Preserve the alternate_buffer of the current window when opening and closing the terminal | 1 |
| g:auto_start_insert | enter insert mode automatically when given focus. Uses BufEnter event | 0 |
| g:open_in_insert_mode | start in insert mode when you open the terminal. Uses BufWinEnter event | 1 |

## Instalation

Use your favourite plugin manager. For example, using [Plug](https://github.com/junegunn/vim-plug):

```vim
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:

```vim
tnoremap (&filetype == "fzf") ? "" : ""
```

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:

```vim
set autowriteall
```

Use [nvr](https://github.com/mhinz/neovim-remote) to avoid nesting nvim in Terminal buffers. This should go in your `.bashrc` or similar:

```bash
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"
```