Skip to content

Instantly share code, notes, and snippets.

@xcoderzach
Created January 26, 2013 22:30
Show Gist options
  • Save xcoderzach/4645082 to your computer and use it in GitHub Desktop.
Save xcoderzach/4645082 to your computer and use it in GitHub Desktop.
func! MoveWithTmux(keypressed,direction)
let k = a:keypressed
let d = a:direction
" get the old window number
let oldw = winnr()
exec "wincmd " . k
let neww = winnr()
" If we are in the same split, we must be at a boundary so tell tmux to switch split
if oldw == neww
" silent so it doesn't show the command.
" call system vs ! so that the screen doesn't flash
exe "call system('tmux select-pane " . d . "')"
end
endfunction
nnoremap <silent><c-j> :call MoveWithTmux('j', '-D')<cr>
nnoremap <silent><c-k> :call MoveWithTmux('k', '-U')<cr>
nnoremap <silent><c-h> :call MoveWithTmux('h', '-L')<cr>
nnoremap <silent><c-l> :call MoveWithTmux('l', '-R')<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment