The default key binding for switching to previous buffer in Vim is CTRL-6 but this does not work from within tmux.
My tmux prefix is CTRL-a if that is relevant.
There are 2 key mappings for editing alternate file. CTRL-6 and CTRL-^
Try pressing Ctrl+Shift+6(which is CTRL-^)
Related
I'm currently using tmux 3.1c; I'd like to bind two keys in order to move the current window in the next/previous session. I want that the window is moved regardless the current session's name/index. The basic idea is that:
if I press e.g. C-b + some <key1>, the current window is moved in the session following the current one, without giving any further input; the window should be moved in the last position of this next session;
if I press e.g. C-b + some <key2> the current window is moved in the session before the current one, without giving any further input; the window should be moved in the last position of this previous session;
On the man pages I found some tokens which act as aliases in order to refer to windows/panes, but no tokens for sessions. I found some interesting examples also here, but no one pointed me to the result I wanted to achieve.
My guess is that in my .tmux.conf I need to set something like
bind-key <key1> move-window -t <target_for_next_session>
bind-key <key2> move-window -t <target_for_previous_session>
(and maybe target the current window somehow too for -s option). I tried to play around with those targets but with no luck. My main guess is that I need to combine the session_id variable in the FORMATS section with the -t option from bind-key, with some +1/-1 increment.
Unfortunately answers for this question always refer to session names/indexes, which are something I don't want to specify.
Thanks in advance!
I have a tmux session called test with several windows, one for each test file. I have another tmux session with vim and the tmuxify plugin. When I tap <f8>, my .vimrc file is programmed to send the <f7> key to the the left pane in window #0 like so:
nmap <buffer> <F8> :execute "silent !tmux send-keys -t test:0.left 'F7'" <bar>:redraw!<CR>
<f7> triggers the test to be run. Works well.
However, notice the test:0.left bit. I have window #0 hardcoded in there. If I want to run the tests in window #7, for example, I first have to swap it with window #0 and then run the test.
What I'd rather do is just send the <f7> key to whatever window in the test session is currently open.
Is there a way to do this?
I consulted ye olde manual. Solution:
test:.left
Leaving the window blank defaults to the current window.
I want to create a tmux keybind which sends a set of keystrokes to the marked pane. This is convenient for implementing a hotkey that runs something so I don't have to manually focus another pane and then come back.
But I'd like for this key to not do anything if there's no marked pane present. I've looked in the manpage and found nothing obvious that I can use to check this state.
To target the marked pane you can use -t '~' or -t '{marked}'.
In this case it is simply a matter of send -t '~' <keys here>.
A more generic way to get the marked pane in your shell would be tmux display -p -t '~' '#D'.
When switching panes in tmux using ^B and cursor keys, what is the quickest way to get out of pane-switching mode and return input handling to the program in the pane?
For instance, you just switched to the shell in your left pane with ^B and Left, and now you want to press Up and Enter to repeat the shell's last command, except tmux steals the Up keypress thinking you're still switching panes.
There has to be a key combo or something to finish pane switching, right?
because pressing arrows is "expensive" keystroke with my keyboard, I hardly use arrow keys.
My vim has ctrl-h,j,kl to switch windows, so I defined in tmux prefix h,j,k,l to switch panes. (my prefix is ctrl-a)
For commandline editing, I don't use any arrow keys either, instead, I use ctrl/alt heavily, my ctrl key is at a good position to press. so re-run last command, I press ctrl-p, enter.
Using ctrl/alt to edit commandline is fast and convenient, since you don't leave your home row.
ctrl-p last cmd
ctrl-h backspace
ctrl-a first col
ctrl-d del current char
ctrl-e eol
ctrl-w remove word backwards
ctrl-b/f back/forward
alt-b/f back/forward a word
alt-d remove word forward
there are a lot more... like ctrl-k, ctrl-u, ctrl-y, alt-. etc.
And if I need edit a really long and complex command, I do ctrl-x ctrl-e, and edit it in my vim.
Since I have my Caps-lock key mapped to Esc (due to Vim), I'd also like it in tmux.
Specifically, I'm trying to set Esc + a as the prefix:
set -g prefix Escape-a
However, this isn't working, and I get the error bad key: Escape-a. Is this because Esc is not a modifier key? I'd really like this to work, as Esc is on the home row and very convenient to use.
This sequence:
set-option -g prefix Escape
unbind-key C-b
bind-key Escape send-prefix
...works for me. I'm using tmux-2.0
If you're on OS X you can achieve this with karabiner.
In your system preferences, change Caps-lock to Control instead of Esc. Then use karabiner to send Esc when you type Control by itself.
karabiner preferences -> "Change Key" tab
scroll down to "Change Control_L Key (Left Control)"
check "Control_L to Control_L (+ When you type Control_L only, send Escape)"
This gives your left pinky easy access to both Esc and Control. You can exit Vim's insert mode the way you already are, and you can set Control+a as your tmux prefix:
set -g prefix C-a
I think this is not possible because Esc and a are 2 distinct keys. From what I know tmux doesn't allow key bindings with more than 1 key (for anything).
This is different from having, for example Ctrl-a as a prefix. Even though we type 2 keyboard keys to get it - ^A is represented as a single character by both tmux and vim.