Vim/tmux split navigation

141 views
Skip to first unread message

aidy lewis

unread,
Jun 27, 2013, 9:37:04 AM6/27/13
to viml...@googlegroups.com
Vimmers, 

I am attempting to integrate Vim/tmux split navigation. 

I have this in my .vimrc

"easy split navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

Which works fine when I am *not* in tmux. 

Following this post: http://robots.thoughtbot.com/post/53022241323/seamlessly-navigate-vim-and-tmux-splits, I have installed the vim-tmux-navigator and added the below to my tmux.conf

#smart pane switching with awareness of vim splits
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"

Mappings work fine for tmux splits, but now not for Vim splits? 

Any help solving this issue is appreciated.

Thanks

Aidy

David Salgado

unread,
Jun 27, 2013, 10:00:24 AM6/27/13
to viml...@googlegroups.com
I've got this working, but using a slightly different setup. Also, I use tmux navigation keys in vim, rather than trying to use vim navigation keys in tmux (i.e. "Ctrl-a h" moves me to the split to the left, whether it's vim or tmux). But, you might find something useful in my tmux conf and vim setup. Both are here;


...that's a deep link to the tmux config, but you'll see where the vim stuff is, easily enough.

Good luck

David



--
You received this message because you are subscribed to the Google Groups "VimLondon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vimlondon+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

aidy lewis

unread,
Jun 27, 2013, 11:13:07 AM6/27/13
to viml...@googlegroups.com
Hi David, 

Thanks for the tips, I stole some things from your tmux.conf. 

My problem was that I was running a version of tmux that wasn't 1.8!

Aidy

Chris Maiden

unread,
Oct 9, 2013, 2:20:00 AM10/9/13
to viml...@googlegroups.com
Hi Aidy,

I'm getting the same behaviour as you describe on vmux 1.8, currently trying to work out why.

I did note that at https://github.com/christoomey/vim-tmux-navigator#vim---tmux-doesnt-work it appears that you don't need/shouldn't have the:

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

mappings in your .vimrc

with or without them, for me, vim -> tmux and tmux ->vim mappings works fine, it's just C+h and C+l not working between vim splits in tmux (outside tmux, C+h, C+j, C+k and C+l all work fine).  
Reply all
Reply to author
Forward
0 new messages