<prefix> space by default switches to the next layout. I never want to do this, as I like to keep it default but sometimes I accidentally trigger it.
In my tmux conf I have:
# unbind prefix-space to rearrage windows
unbind C-Space
But it doesn't seem to do the trick. What am I missing?
next-layout binding is bound to Space not C-Space so you basically need to
unbind Space
Don't forget to source your tmux.conf after this
tmux source-file ~/.tmux.conf
Related
Lately, when using Vim in tmux over ssh, sometimes something happens where Vim starts ignoring all my mappings that start with Ctrl: for instance <C-P>, which I have bound to the CtrlP plugin. Instead, Vim runs the builtin action (in this case, moving lines upward in the file). I don't doubt that the correct keypress is reaching Vim, as it uses the correct builtin action associated with <C-P> (using :send-keys to send ctrl-p from tmux also causes the builtin <C-P> in vim to run, instead of the mapping).
All my mappings not involving the control key still work. For instance, I can do this:
nnoremap p :echo "test"<cr>, and pressing p echoes test
But then immediately after,
nnoremap <c-p> :echo "test"<cr>, and pressing CTRL-P doesn't echo test, it moves the cursor up one line.
Restarting Vim always fixes the issue, but at some point, something I do causes the problem to surface again. I've been working mostly in tmux through ssh lately, so I'm not 100% sure if either one of those are the problem (although I think I recall this happening once in Vim in tmux not over ssh), but as mentioned above, I believe using send-keys directly from tmux as a test is ensuring that vim is getting the actual ctrl-p keycode. As well, <C-V><C-P> in insert mode does actually insert ^P.
Note that although I've used ctrl-p here as an example, since it's a key I actually use a lot in practice, this applies to any control key mapping.
Is there some kind of Vim state I don't know about that's causing this to happen? Is this likely a terminal problem? What are my next steps?
I would like to use tmux+vim. I find very convenient to use the mouse as well to select text. I also use the behave mswin in vim in order to sometime use the to select text.
Unfortunately Tmux already uses the Shift key. Can I bind it to another char or just unbind it?
When I'm not in insert mode and I'm navigating around my file with the motion keys (hjkl etc), the keys often appear in the buffer (illustrated below). I can observe this effect pretty readily in tmux, but it doesn't seem to happen without. If I run :!reset in vim the buffer returns to normal, but it doesn't stay that way for long. I'm not sure why this is happening and google yielded nothing. Halp?
Edit: It seems just a simple :e will fix the problem, too.
I experience the same thing. A few extra observations:
it only seems to happen when I hold down a motion key like j or k, causing rapid repeats
it happens both in and outside of tmux, but much more often in tmux
it happens much more often since I enabled vim-go's go_auto_sameids, which I believe is making a call to an external program (guru) for every cursor movement
This leads me to assume that it's a timing issue in vim that is exacerbated by latency added by things like tmux and/or plugins.
(Using gnome terminal; $TERM is screen-256color in tmux and xterm-256color outside)
I think this was alluded to on the tmux mailing list recently. Try decreasing the value of the escape-time parameter in tmux, so that tmux more quickly sends the escape character to vim to return to command mode, rather than waiting for more characters in an escape sequence. The default value is 500ms, so try something smaller, like 50.
In .tmux.conf:
set-option -g escape-time 50
When I run Vim inside Tmux, I have to press the tab key two times to get the keypress registered. I googled around for a while, to no avail, and I don't h ave this problem when I use Vim outside of Tmux. Is the tab key reserved for something I'm not aware of?
How do I fix this?
I haven't really configured anything in tmux besides remapping C-b to C-i.
set -g prefix C-i
unbind C-b
bind C-i send-prefix
While Tab and the Control-i are usually distinguished in GUI environment, they generate the same character in tty-based environments like terminal emulators. That character is U+0009, which is the Tab control character. It is represented as the single byte 0x09 in ASCII, UTF-8 and many other encodings. All of the “C0 control codes” (ASCII 0-31) have keyboard equivalents that combine the Control key with another key (mostly letters, but also some symbols). The Tab control character is generated by Control-i.
You can verify that (at least) tmux considers C-i and Tab to be the same by looking at the output of tmux show-options -g | grep prefix. You will see it has set your prefix to the key named Tab, even though you specified it as C-i in your configuration. You can also notice the same canonicalization in the output of tmux list-keys | grep prefix.
You may want to pick a different prefix if you do not want to type Tab twice when you want to send one to programs running inside tmux.
I'm trying to a get a ctrl+tab and ctrl+shift+tab binding to work inside of a tmux session (I'm also using PuTTY).
I already went through the pains of having to recompile PuTTY so it would send ctrl and shift correctly. After using ctrl+v, and I'm able to see that ^[[27;5;9~ and ^[[27;6;9~ are being sent for ctrl+tab and ctrl+shift+tab, respectively. Is there any way I can get these bound to next-window and previous-window inside of tmux?
Edit:
After some research, I'm thinking I might have to configure xterm to include those keycodes. Any idea how I would go about doing that?
Edit2:
So I found out I can retrieve infocmp and recompile it. I added
kctab=\E[27;5;9~, kcstab=\E[27;6;9~,
to the end of it, except now it's giving me an error. "entry does not start with terminal names in column one"
Recent “unreleased” versions of tmux do automatically recognize those xterm-style key sequences once you have your terminal sending them (no need to change your terminfo entry). The next release version (1.8?) should also have this support. With an appropriate build of tmux1, all you have to do is bind the keys in your tmux configuration:
bind-key C-Tab next-window
bind-key C-S-Tab previous-window
You will still need to type your prefix key before these keys.
(Note: ~/.tmux.conf is only processed when the server starts. If you make changes to it, you will either need to exit all your sessions and restart the server, or use (e.g.) tmux source ~/.tmux.conf to have your existing server re-process the file.)
Also, if you want tmux to pass along these (and other) xterm-style key sequences to programs running inside tmux, then you will need to enable the xterm-keys window option.
set-option -gw xterm-keys on
(If you prefer, you can do this on a per-window basis by using -w instead of -gw.)
If you want to be able to use those keys without typing the prefix, then you can use “no prefix” bindings instead:
bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window
This will more or less “dedicate” the keys to tmux, though. It will be difficult to type these keys to any program running inside tmux (e.g. you would have to use the tmux command send-keys C-Tab—as normal, xterm-keys must be enabled to send these xterm-style key sequences).
The problem with your terminfo entry editing is probably because each line after the one that names the terminal type needs to start with a Tab. Lines that do not start with a tab are the beginning of a new terminal entry. Technically, the NL TAB sequence is basically a line continuation in this file format; each entry is a single logical line.
Also, if you are redefining terminfo entries, be sure to use -x with infocmp and tic to preserve the user-defined capabilities (some of which are fairly standard).
1 I.e. built from recent code in the tmux Git repository at sf.net (at the clone-able URL git://git.code.sf.net/p/tmux/tmux-code).