@acandael Can you please open an issue on the
vim-tmux-navigator repo rather than posting in this thread?
@acandael Can you please open an issue on the
when I run run Rspec from within Vim, my spec file is replaced with a new window that runs the spec file. When I hit return I return to the spec file. However I would prefer that the spec is run in a new pane, like in the tutorial video.
I installed the .dotfiles with the Thoughtbot Laptop script.
In my .vimrc file the following lines specify the vim-rspec configuration:
" vim-rspec mappings nnoremap <Leader>t :call RunCurrentSpecFile()<CR> nnoremap <Leader>s :call RunNearestSpec()<CR> nnoremap <Leader>l :call RunLastSpec()<CR>
am I missing something?
Thanks for your help,
Thanks Ben. Yesterday I found this blog post on dispatch.vim:
When I use Vim from within tmux, the delete key (or
Ctrl-H) sends a
^? character instead of a backspace, i.e.:
YOU WILL BE DELETED^?^?^?^?^?^?^?^?
This doesn’t happen elsewhere in tmux, not does it happen in Vim outside tmux. This is surely related to my other problem with Ctrl-H failing to switch panes. As was the case there, toggling the
Delete Sends Ctrl-H setting has no effect here. Any idea what the
^? is or what’s wrong with my
@captain_zoom not sure what the specific issue is, but if you are only seeing this behavior in Vim, you can check what the mapping in Vim is by running:
Other things to look at would be comparing the behavior in and out of tmux, and looking into your tmux mappings if you’re using Vim-Tmux-Navigator.
Thanks @christoomey – I just removed all the
<c-h> mappings in my .vimrc, and the problem persists. I now have:
:imap <c-h> no mapping found :nmap <c-h> no mapping found :map <c-h> s <C-H> * <C-G>c
I can remove that last mapping by typing
unmap <c-h>, but that doesn’t change anything. (Interestingly,
unmap <c-h> doesn’t work when it’s the last line in my .vimrc. Somehow that mapping is getting set after .vimrc loads?)
Regardless, I don’t think a mapping is the problem, because the problem is unique to Vim inside tmux. I have no issues (with or without my normal
C-h mappings) in gui MacVim, terminal MacVim, or the default Vim, as long as they are run outside of tmux. Not using Vim-Tmux-Navigator at the moment.
I have applied some the tmux and vim configuration in this course. But now when I use vim inside iTerm but outside of tmux, every time I leave insert mode the string tmux; is inserted in the current buffer.
This only happens inside the terminal NOT in Macvim.
Hello @geraldspreer, Not sure what the cause of that would be, although you can likely rule out the tmux.conf file as you said this is happening outside of tmux. I would try disabling parts of the new configuration to try to lock down what line is causing it.
Found the solution:
Updated my .vimrc to:
if exists('$TMUX') let &t_SI = "\<Esc>[3 q" let &t_EI = "\<Esc>[0 q" " these two lines were outside the if statement " putting them here solves this issue although the cursor shape stays " the same in any mode outside tmux - but that's OK. let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" endif
Thank you for pointing me towards this.
Hi @geraldspreer, are you using Neovim? Neovim had an issue until very recent builds, but even if you aren’t using Neovim there’s some interesting info about terminal types and emulation. Here’s the issue report:
I had this issue only in tmux for a while. I mapped
<C-h> to be the backspace key in normal mode to work around it until the recent fix.
Thanks for the hint.
When I try to run the specs in the current file, vim-rspec seems to be getting the path wrong. It assumes the path to be
This is even if I cd to the spec file’s subdirectory and launch vim with the spec as a command line argument. At first I thought it was because I was finding the file with Ctrl-P, but that’s not it.
EDIT: Actually, I’m wrong. If I launch vim in the subdirectory containing the spec file, when Vim-Rspec passes off that filename, RSpec has no problem loading it. BUT in this case, Rspec can’t load ‘rails_helper’ which is in the require line of that spec file. So if I’m in project root, vim-rspec isn’t telling Rspec where the spec file is located – it’s just letting RSpec assume that it’s the same directory from which vim was launched. And if launched from the subdirectory, Rspec doesn’t know where to look for the helper files. Either way, the lack of awareness of where the file is located is fatal.
Note that running “All Specs” works just fine. It’s just the commands that require a specific filename that are getting broken.
@MatthewMDavis, have you tried running from the root?
For reference, rspec.vim uses @% to determine the file path. You can confirm the output by running
:echo @% in Vim. This should match the path you would need to run in vim.
One other setting to look at is
autochdir. You can determine the value by running
:verbose set autochdir?. You’ll either see
noautochdir, or the last file that set it. If set, that could be interfering.
I had just found out that a directory switch within vim was causing my problem right before I saw your message, and now I know what .vimrc setting was doing it to me: yes, vim was autochdir’ing to the spec file’s directory, and vim in turn was spawning a tmux runner pane, in a subdirectory where rspec didn’t know how to locate rails_helper.
Having turned off autochdir, things are working as expected (as long as I’m working in the Rails project root).
That was a bear of a morning. Thanks for your help. Nice course, too. I don’t know if I’ll spend 100% of my time in Tmux, but the number is definitely going way up.
Happy to help! If you’re anything like me then tmux’s addictive efficiency will soon take you over.
Great job @christoomey ! Really !
But i’ve got a problem with vim-tmux-runner.
When I try to launch RunNearestSpec, I’ve got an error in the runner pane :
There is a ^L before the command !
How can I fix it ?
(FYI, when i’m using :VtrSendLinesToRunner, there is no problem at all, it works)
Thanks for your answer
Hello @krichtof, thanks for the kind words!
^L is purposeful, it is meant to clear the terminal before running the command but it seems like your terminal is not interpreting the
^L as a clear.
Thanks for your answer. When I disable the VtrClear, it works
Hi @christoomey, thanks for putting this together, it’s pretty awesome.
I’ve always used C-l to clear the terminal and C-k to delete the rest of the line I’m on. With the tmux key bindings that you have setup to navigate panes, those keystrokes are being caught by tmux and never making it to the terminal. I was thinking that I could create a config where hitting C-l C-l would do the same thing, but that gets complicated with the vim integration that was just added. Any suggestions?