8000 Vi-like bindings for tmux? · Issue #154 · wincent/wincent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Vi-like bindings for tmux? #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rieje opened this issue Mar 3, 2025 · 1 comment
Closed

Vi-like bindings for tmux? #154

rieje opened this issue Mar 3, 2025 · 1 comment

Comments

@rieje
Copy link
rieje commented Mar 3, 2025

Hey, just curious why you don't use setw -g mode-keys vi for vi-like bindings for tmux, or more comprehensive vim bindings, It seems like you only try to use some of these bindings for copy mode and window movement.

Do you think it doesn't work as well in tmux? I know some veteran vim users still prefer e.g. emacs over vim-mode for their interactive shell. Or perhaps there's value in sticking with the defaults where possible, though I don't see that point in that unless one already makes such insignificant changes from the defaults.

@wincent
Copy link
Owner
wincent commented Mar 3, 2025

I do effectively use mode-keys vi, because I have EDITOR set to nvim (or vim as a fallback). From man tmux:

mode-keys [vi | emacs]
             Use vi or emacs-style key bindings in copy mode.
             The default is emacs, unless VISUAL or EDITOR
             contains ‘vi’.

It's true that I could add some more bindings beyond the ones you get with mode-keys vi like the ones in that article you link to, like y to yank. I wouldn't want to go too far with that though, so as not to run into conflicts with some default bindings (y is good because it does nothing in copy-mode-vi).

@rieje rieje closed this as completed Mar 3, 2025
wincent added a commit that referenced this issue Mar 4, 2025
Make them a bit more (but not entirely) Vim-like. Inspired by:

- #154

`y` is currently unbound, so can be trivially set to the same as
`Enter`.

`v`, `C-v`, and `V` all have existing bindings. We make them a bit more
Vim-like:

- `v`: Before, toggled rectangular selection mode. Now, the first `v`
  engages `VISUAL` mode and the second `v` disengages it.
- `V`: Before, always started a new `VISUAL LINE` selection. Now, the
  first `V` engages `VISUAL LINE` mode and the second `V` disengages it.
- `C-v`: Before, toggled rectangular selection mode. Now, the first
  `C-v` engages `VISUAL BLOCK` mode and the second `C-v` disengages it.

This is different from Vim, where if I press `v`, `V`, then `C-v`, I'll
first enter `VISUAL` mode, and then `VISUAL LINE` and then `VISUAL
BLOCK`.

I could make this more like Vim with a bit of work: ie. I could set a
variable when entering each mode to show which mode I'm in (eg. `VISUAL`
could be `1`, `VISUAL LINE` could be `2`, and `VISUAL BLOCK` could be
`3`), and then I could check the value in each of the bindings; ie:

- If you hit `v`, I could set the value to `1`.
- If you then hit `V`, I go to `VISUAL LINE` if the value is not `2`;
  otherwise I would clear the selection.

Not sure if I can be bothered doing that right now (I'd have to change
all the places that you can get into the `VISUAL` modes, such as mouse
bindings), but I think I'll do it in a future iteration.
4835
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0