changeset 189:925861e874ec

Add vim-tmux-navigator for seamless navigation
author zegervdv <zegervdv@me.com>
date Sat, 08 Nov 2014 19:22:00 +0100
parents 51d25ca2f262
children 35664e63555d
files tmux.conf vimrc
diffstat 2 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tmux.conf	Sat Nov 08 19:01:14 2014 +0100
+++ b/tmux.conf	Sat Nov 08 19:22:00 2014 +0100
@@ -11,13 +11,20 @@
 set -g status-keys vi
 # bind-key -t vi-edit Up
 # bind-key -t vi-eidt Down
-bind h select-pane -L
-bind j select-pane -D
-bind k select-pane -U
-bind l select-pane -R
+# bind h select-pane -L
+# bind j select-pane -D
+# bind k select-pane -U
+# bind l select-pane -R
 bind-key -r C-h select-window -t :-
 bind-key -r C-l select-window -t :+
 
+# Move between tmux and vim seamlessly
+bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
+bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
+bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
+bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
+bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
+
 #act like GNU screen
 unbind C-b
 set -g prefix C-a
--- a/vimrc	Sat Nov 08 19:01:14 2014 +0100
+++ b/vimrc	Sat Nov 08 19:22:00 2014 +0100
@@ -27,6 +27,7 @@
 " Tmux
 Plug 'benmills/vimux', { 'on': 'VimuxRunCommand' }
 Plug 'edkolev/tmuxline.vim', { 'on': 'TmuxlinSnapshot' }
+Plug 'christoomey/vim-tmux-navigator'
 
 " Search and Complete
 Plug 'Shougo/neocomplete'
@@ -249,10 +250,10 @@
 vnoremap <TAB> %
 
 " Move between splits
-map <C-j> <C-w>j
-map <C-k> <C-w>k
-map <C-l> <C-w>l
-map <C-h> <C-w>h
+" map <C-j> <C-w>j
+" map <C-k> <C-w>k
+" map <C-l> <C-w>l
+" map <C-h> <C-w>h
 
 " highlight last inserted text
 nnoremap gV `[v`]
@@ -567,7 +568,9 @@
 " After-objects {{{
 autocmd VimEnter * call after_object#enable('=', ':', '-', '#', ' ')
 " }}}
-
+" Vim-tmux-navigator {{{
+" nnoremap <silent> <C-h> :TmuxNavigateLeft<CR>
+" }}}
 " Load local vimrc
 if filereadable($HOME . "/.vimrc.local")
   source ~/.vimrc.local