Open mefp opened 5 years ago
update: I found an .inputrc file I had forgotten about but removing it did not change things.
Can you check the output of tmux list-keys | grep 'C-[hjkl]'
in your shell? I want to confirm that the tmux bindings are properly being set by tpm.
Related, can you check the output of :verbose nmap <C-j>
in Vim?
Lastly, on the Vim side it looks like you have an explicit set of key bindings:
"split navigations...
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
These will conflict with tmux-navigator and should be removed. I'd be interested in the output of :verbose nmap <C-j>
both before you remove the extra mappings, and after for comparison.
Thank you @christoomey for pointing that out and for the response.
Output of tmux list-keys | grep 'C-[hjkl']
:
bind-key -T copy-mode C-k send-keys -X copy-end-of-line
bind-key -T copy-mode-vi C-h send-keys -X cursor-left
bind-key -T copy-mode-vi C-j send-keys -X copy-selection-and-cancel
Output of :verbose nmap <C-j> in Vim
:
Before removing existing bindings
<NL> * :TmuxNavigateDown<CR>
Last set from ~/.vim/bundle/vim-tmux-navigator/plugin/tmux_navigator.vim line 20
After commenting-out existing bindings (and restart)
n <NL> * :TmuxNavigateDown<CR>
Last set from ~/.vim/bundle/vim-tmux-navigator/plugin/tmux_navigator.vim line 20
I think got this to work following the instructions here: https://thoughtbot.com/blog/vim-splits-move-faster-and-more-naturally
I changed:
Plugin 'christoomey/vim-tmux-navigator'
to
Bundle 'christoomey/vim-tmux-navigator'
and I removed
let mapleader = " "
from .vimrc
I am having this same problem, including the same output fortmux list-keys | grep 'C-[hjkl']
and :verbose nmap <C-j>
as mefp
OS: Mac OS 10.14.5 (Mojave) Terminal App v2.9.5 tmux 2.9a vim version 8.1.1517
~/.tmux.conf
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\ select-pane -l
~/.vimrc
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)
" ...
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/nerdtree'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'kien/ctrlp.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
set incsearch
set ruler
set number
function! MoveLeft()
let newpos = getpos('.')
let newpos[2] -= 1
if (newpos[2] < 1)
let newpos[2] = 1
endif
call setpos('.', newpos)
return ""
endfunction
inoremap ( ()<C-R>=MoveLeft()<CR>
let mapleader = " "
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:SimpylFold_docstring_preview=1
syntax on
imap kj <Esc>
let python_highlight_all=1
syntax on
command Nt NERDTreeToggle
PS - copied this config over to my Ubuntu machine and it worked fine. I assume the issue is related to MacOS.
Same problem here on macOS
I just added these lines to the bottom of my vimrc:
nmap <C-j> :TmuxNavigateDown<cr>
nmap <C-k> :TmuxNavigateUp<cr>
nmap <C-l> :TmuxNavigateRight<cr>
imap <C-h> :TmuxNavigateLeft<cr>
imap <C-j> :TmuxNavigateDown<cr>
imap <C-k> :TmuxNavigateUp<cr>
imap <C-l> :TmuxNavigateRight<cr>
What is weird is that the TmuxNavigate* commands work if I enter them manually.
@mschwartz Works like a charm, been looking for this
Sorry, but it still doesn’t work for me.
Oddly, if I ssh into a Linux box and tmux + vim there, it works. Same iterm2, just different host.
Ctrl j does move from vim to a shell pane and back.
It seems to be something specific to vim or nvim running within tmux within iterm2 on Catalina.
@mschwartz Is it on purpose that you left out
nmap <C-h> :TmuxNavigateLeft<cr>
Oddly, it magically started working today.
It could be I rebooted, updated other software, etc.
I REALLY appreciate this plugin. I use i3wm. And vim+tmux for all my editing. alt+hjkl change applications (windows) and ctrl-hjkl work within tmux session.
I cannot fathom using a gui version of vim anymore. There simply isn't any editing setup as powerful and efficient as vim and tmux and this plugin.
Thanks!
D'oh. Scratch that last comment.
It still fails here. I wasn't running in tmux, and outside tmux the keys work.
So, bug still exists.
nmap <C-h> :TmuxNavigateLeft<cr>
nmap <C-j> :TmuxNavigateDown<cr>
nmap <C-k> :TmuxNavigateUp<cr>
nmap <C-l> :TmuxNavigateRight<cr>
imap <C-h> :TmuxNavigateLeft<cr>
imap <C-j> :TmuxNavigateDown<cr>
imap <C-k> :TmuxNavigateUp<cr>
imap <C-l> :TmuxNavigateRight<cr>
map <C-h> :TmuxNavigateLeft<cr>
map <C-j> :TmuxNavigateDown<cr>
map <C-k> :TmuxNavigateUp<cr>
map <C-l> :TmuxNavigateRight<cr>
Not sure what I did to get it working but it is for me (OSX Mojave 10.14.6)
.vimrc (other stuff omitted for brevity)
" for navigating panes in tmux and vim
Plugin 'christoomey/vim-tmux-navigator'
call vundle#end() " required
.tmux.conf (some stuff omitted for brevity)
# Smart pane switching with awareness of vim splits
bind -n C-k run-shell 'tmux-vim-select-pane -U'
bind -n C-j run-shell 'tmux-vim-select-pane -D'
bind -n C-h run-shell 'tmux-vim-select-pane -L'
bind -n C-l run-shell 'tmux-vim-select-pane -R'
bind -n "C-\\" run-shell 'tmux-vim-select-pane -l'
I'm on Catalina.
I had the same issue as OP and solved it by switching from TPM to snippet in tmux.conf
.
macOS Catalina, Mac Terminal, tmux 3.0a, NVIM v0.4.3
Fwiw, I fixed this a month ago and my issue has to do with pipenv.
I changed from this (from the README):
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
to this: https://github.com/sagittaros/dotfiles/blob/master/bin/isvim2
It has worked perfectly ever since. Ymmv
I'm having what seems to be the opposite problem to some other issues here. If inside of vim, I can use the key bindings to navigate to a tmux pane. However, if I try to get back into vim or to another tmux pane, nothing works.
OS: Mac OS 10.14.5 (Mojave) Terminal App v2.9.5 echo $TERM output in tmux session =
screen-256color
Tmux 2.9a Vim 8.1.950~/.tmux.conf
~/.vimrc