Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make vim-style key bindings work on tmux using set-window-option?

Tags:

tmux

I am aware that I can manually bind individual keys in my .tmux.conf file, but according to this page I should be able to get vim-like key bindings in tmux simply by adding the following to my .tmux.conf, saving me having to maintain a list of keybindings:

set-window-option -g mode-keys vi

But this doesn't really seem to work as expected. Sure enough, when I press Ctrl+b [ I am able to navigate through my terminal history using vim keys hjkl, but when I press Ctrl+b k it doesn't take me to the above window, for that I still have to press Ctrl+b Up, same goes for down, left and right.

Why doesn't this work? Do I really have to map these keys manually on top of vi mode to get actual vi mode?

I'm using tmux 1.6

like image 868
quant Avatar asked Jun 18 '14 23:06

quant


People also ask

How do I use Vim mode in tmux?

Once vimux is installed, you can access the command prompt from within vim by running :VimuxPromptCommand . You can then immediately start typing your shell command. Pressing enter will run the command in a tmux pane in the current window. If necessary, vimux will create a new pane for the command to run in.

How do you use key bindings tmux?

tmux may be controlled from an attached client by using a key combination of a prefix key, 'C-b' (Ctrl-b) by default, followed by a command key. The default command key bindings are: C-b Send the prefix key (C-b) through to the application. C-o Rotate the panes in the current window forwards.

What is vi mode in tmux?

tmux offers a set of vi-like bindings for navigating a buffer in a window. These allow you to not only navigate through the buffer beyond what your screen is currently showing, but also to search all the output generated thus far, and to select and copy text that can be pasted in any other window in the tmux session.

What are Vim key bindings?

By Vim, I mean literally Vim, the command-line text editor. And by bindings, I mean keyboard commands that do specific things in the editor.


1 Answers

add this to your cnofig:

#switch panels
bind k selectp -U # switch to panel Up
bind j selectp -D # switch to panel Down 
bind h selectp -L # switch to panel Left
bind l selectp -R # switch to panel Right
like image 186
Kent Avatar answered Oct 20 '22 14:10

Kent