TLDR
- Vim 8.1 introduced terminal mode,
:terminal :terminalallows you to open terminals inside Vim, hence the potential to be as productive as being in a Tmux session- You probably don't need it if you are already using Tmux
How is This Helpful?
In Vim, prior to this, we can only access the shell through either typing :!, to and back from shell with hitting CTRL + Z then using $ fg , or Tmux.
Now, with the new ternimal mode, combining tabs, we can work wonders with just Vim! In cover photo, I have
- One tab with a file I am edting, a test watcher, and a terminal for working in Git
- The other tab with some other file in another area of the code base
Use Case
- Checking Git log
- Running a server or some services
- Watching files
- Pretty much anything you would otherwise do with
CTRL + Zfor :)
Getting Started
My Setup
" ~/.vimrc
" Split to the right for vsp
set splitright
" Split to the bottom for sp
set splitbelow
" <leader> + t: Opens a termnial vertically
" Credit: https://medium.com/gr-tech/vim-without-tmux-3ebee29fc71a
nnoremap <silent> <leader>t :vert term<CR>Working with Terminal Mode
- With the setup, you can open a terminal with
<leader> + t - Move among the panes with
CTRL + w + h/j/k/l - Go to terminal Normal mode with
CTRL + w + Nto copy the text; - Hit
ito go back to terminal mode - Use Vim's Ex command in terminal pane with
CTRL + w + : - From there, type command
:termto open another terminal pane below the current pane
References
-
:h terminal -
Vim 8.1 Release Note on vim.org/