Skip to content

Commit

Permalink
[vim] Convenient terminal behaviour
Browse files Browse the repository at this point in the history
Alt+T to toggle a 12-row high split at bottom
  • Loading branch information
bjeanes committed Aug 24, 2020
1 parent 0d6565f commit 12b8e40
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions editors/vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,34 @@ nnoremap zS :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:v
" https://github.com/phoenixframework/phoenix/issues/1165#issuecomment-437130681
let $MIX_ENV='test'

" Terminal Function
" Courtesy of https://www.reddit.com/r/vim/comments/8n5bzs/using_neovim_is_there_a_way_to_display_a_terminal/dzt3fix
let g:term_buf = 0
let g:term_win = 0
function! TermToggle(height)
if win_gotoid(g:term_win)
hide
else
botright new
exec "resize " . a:height
try
exec "buffer " . g:term_buf
catch
call termopen($SHELL, {"detach": 0})
let g:term_buf = bufnr("")
set nonumber
set norelativenumber
set signcolumn=no
endtry
startinsert!
let g:term_win = win_getid()
endif
endfunction
nnoremap <silent> <leader>te :call TermToggle(12)<CR>
nnoremap <A-t> :call TermToggle(12)<CR>
inoremap <A-t> <Esc>:call TermToggle(12)<CR>
tnoremap <A-t> <C-\><C-n>:call TermToggle(12)<CR>
if filereadable(expand('~/.vimrc.local'))
source ~/.vimrc.local
endif

0 comments on commit 12b8e40

Please sign in to comment.