loading...

Fun vi shortcut to open a terminal in vi

casonadams profile image Cason Adams ・1 min read

I prefer to use tmux for multiplexing terminals. However, I just learned / figured out how to kind of make this work like I do with tmux. Mind you not as flexible.

Add this snippet to vimrc or init.vim file

init.vim

nmap <Leader>t :call Terminal()<CR>

function! Terminal()
  :set splitbelow
  :set splitright
  :10split
  :set laststatus=0
  :set scl=no
  :set nonu
  :term
endfunction

autocmd TermOpen * startinsert

tnoremap <Esc> <C-\><C-n> <bar> :call ExitTerminal()<CR>
function! ExitTerminal()
  :set nosplitbelow
  :set nosplitright
  :set laststatus=2
  :set scl=yes
  :set number
  :q!
endfunction

Now when you <Leader>t you will drop into a terminal in vi

Notes

To exit use <Esc>

Discussion

pic
Editor guide