Skip to content

Instantly share code, notes, and snippets.

@smlb
Created July 6, 2017 14:49
Show Gist options
  • Save smlb/edc1d91f4a90fcb7aeb38b12a38d4194 to your computer and use it in GitHub Desktop.
Save smlb/edc1d91f4a90fcb7aeb38b12a38d4194 to your computer and use it in GitHub Desktop.
terminal function gsora.xyz
autocmd! BufWritePost * Neomake
" 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