Skip to content

Instantly share code, notes, and snippets.

@jteneycke
Forked from Garoth/term-config.vim
Created February 6, 2017 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jteneycke/5958aa307677426a86e1d88a3d78332c to your computer and use it in GitHub Desktop.
Save jteneycke/5958aa307677426a86e1d88a3d78332c to your computer and use it in GitHub Desktop.
" Window split settings
highlight TermCursor ctermfg=red guifg=red
set splitbelow
set splitright
" Terminal settings
tnoremap <Leader><ESC> <C-\><C-n>
" Window navigation function
" Make ctrl-h/j/k/l move between windows and auto-insert in terminals
func! s:mapMoveToWindowInDirection(direction)
func! s:maybeInsertMode(direction)
stopinsert
execute "wincmd" a:direction
if &buftype == 'terminal'
startinsert!
endif
endfunc
execute "tnoremap" "<silent>" "<C-" . a:direction . ">"
\ "<C-\\><C-n>"
\ ":call <SID>maybeInsertMode(\"" . a:direction . "\")<CR>"
execute "nnoremap" "<silent>" "<C-" . a:direction . ">"
\ ":call <SID>maybeInsertMode(\"" . a:direction . "\")<CR>"
endfunc
for dir in ["h", "j", "l", "k"]
call s:mapMoveToWindowInDirection(dir)
endfor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment