Permalink
Browse files

replace tmux script with vim-tmux-navigator plugin

Thanks, @christoomey!
  • Loading branch information...
1 parent 0c630e1 commit 799089104afdebcd22b6aa17f92dba1ef073e3c3 @mislav committed Jun 22, 2013
Showing with 4 additions and 38 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 bundle/tmux-navigator
  3. +0 −38 plugin/tmux_navigator.vim
View
@@ -82,3 +82,6 @@
[submodule "bundle/visual-star-search"]
path = bundle/visual-star-search
url = https://github.com/nelstrom/vim-visual-star-search
+[submodule "bundle/tmux-navigator"]
+ path = bundle/tmux-navigator
+ url = https://github.com/christoomey/vim-tmux-navigator
Submodule tmux-navigator added at f0a3f6
View
@@ -1,38 +0,0 @@
-" Maps <C-h/j/k/l> to switch vim splits in the given direction. If there are
-" no more windows in that direction, forwards the operation to tmux.
-" Additionally, <C-\> toggles between last active vim splits/tmux panes.
-
-if $TMUX != ''
-
- let s:tmux_is_last_pane = 0
- au WinEnter * let s:tmux_is_last_pane = 0
-
- " Like `wincmd` but also change tmux panes instead of vim windows when needed.
- function s:TmuxWinCmd(direction)
- let nr = winnr()
- let tmux_last_pane = (a:direction == 'p' && s:tmux_is_last_pane)
- if !tmux_last_pane
- " try to switch windows within vim
- exec 'wincmd ' . a:direction
- endif
- " Forward the switch panes command to tmux if:
- " a) we're toggling between the last tmux pane;
- " b) we tried switching windows in vim but it didn't have effect.
- if tmux_last_pane || nr == winnr()
- let cmd = 'tmux select-pane -' . tr(a:direction, 'phjkl', 'lLDUR')
- call system(cmd)
- let s:tmux_is_last_pane = 1
- echo cmd
- else
- let s:tmux_is_last_pane = 0
- endif
- endfunction
-
- " navigate between split windows/tmux panes
- nmap <c-j> :call <SID>TmuxWinCmd('j')<cr>
- nmap <c-k> :call <SID>TmuxWinCmd('k')<cr>
- nmap <c-h> :call <SID>TmuxWinCmd('h')<cr>
- nmap <c-l> :call <SID>TmuxWinCmd('l')<cr>
- nmap <c-\> :call <SID>TmuxWinCmd('p')<cr>
-
-end

0 comments on commit 7990891

Please sign in to comment.