Skip to content
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

Support more vim keybinds #2119

Open
3 tasks done
dxrcy opened this issue Dec 30, 2024 · 2 comments · May be fixed by #2143
Open
3 tasks done

Support more vim keybinds #2119

dxrcy opened this issue Dec 30, 2024 · 2 comments · May be fixed by #2143
Labels
feature New feature request good first issue Good for newcomers

Comments

@dxrcy
Copy link

dxrcy commented Dec 30, 2024

yazi --debug output

Yazi
    Version: 0.4.2 (Arch Linux 2024-12-28)
    Debug  : false
    Triple : x86_64-unknown-linux-gnu (linux-x86_64)
    Rustc  : 1.83.0 (90b35a62 2024-11-26)

Ya
    Version: 0.4.2 (Arch Linux 2024-12-28)

Emulator
    Brand.from_env      : Some(Kitty)
    Emulator.detect     : Emulator { kind: Left(Kitty), light: false, cell_size: Some((14, 29)) }
    Emulator.detect_full: Ok(Emulator { kind: Left(Kitty), light: false, cell_size: Some((14, 29)) })

Adapter
    Adapter.matches: Kgp

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-1")
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: Some("0bd541f2fd902dbfa04c3ea2ccf679395e316887_1735515382_248783120")
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

NVIM
    NVIM          : false
    Neovim version: 0.10.3

Variables
    SHELL           : Some("/usr/bin/zsh")
    EDITOR          : Some("nvim")
    VISUAL          : None
    YAZI_FILE_ONE   : None
    YAZI_CONFIG_HOME: None
    YAZI_ZOXIDE_OPTS: None
    FZF_DEFAULT_OPTS: None

Text Opener
    default     : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-create: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-rename: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : 2
    tmux version       : tmux 3.5a
    tmux build flags   : enable-sixel=Unknown
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file          : 5.46
    ueberzugpp    : No such file or directory (os error 2)
    ffmpeg/ffprobe: 7.1 / 7.1
    pdftoppm      : 24.12.0
    magick        : 7.1.1-43
    fzf           : 0.57.0
    fd/fdfind     : 10.2.0 / No such file or directory (os error 2)
    rg            : 14.1.1
    chafa         : No such file or directory (os error 2)
    zoxide        : 0.9.6
    7z/7zz        : 24.09 / No such file or directory (os error 2)
    jq            : 1.7.1

Clipboard
    wl-copy/paste: 2.2.1 / 2.2.1
    xclip        : 0.13
    xsel         : No such file or directory (os error 2)

Please describe the problem you're trying to solve

Missing keybinds, for dialog inputs:

  • r to replace a single character.
  • _ and ^ to jump to the first non-whitespace character in the line.
  • W to jump to the next WORD start.
  • B to jump to the previous WORD start.
  • E to jump to the end of the next WORD end.

'WORD' here meaning a sequence of characters delimited only by whitespace, not punctuation.

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

Implement these keybinds for dialog inputs.

Additional context

Similar to #770.

Additionally, I jumps to the first character in the line, instead of the first non-whitespace character. This is not consistent with vim, so I will open a separate bug report for this.

Checklist

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature
@sxyazi
Copy link
Owner

sxyazi commented Dec 30, 2024

Sounds good to me, it would be a great enhancement for the user experience and shouldn't add too much maintenance overhead:

  • For r, we can add a new replace command and introduce a new Replace mode here:

    pub enum InputMode {
    Normal,
    #[default]
    Insert,
    }

  • For _ and ^, we could add a new parameter move first-char to the move command:

  • For W and E, we could add a --big parameter to the forward command so that it moves only by spaces, not punctuation, i.e.:

    • W -> forward --big
    • E -> forward --big --end-of-word
  • For B, we could add a --big parameter to the backward command so that it moves only by spaces, not punctuation

Would you like to raise a PR for it?

@sxyazi sxyazi added the good first issue Good for newcomers label Dec 30, 2024
@dxrcy dxrcy linked a pull request Jan 2, 2025 that will close this issue
5 tasks
@dxrcy
Copy link
Author

dxrcy commented Jan 2, 2025

@sxyazi I opened a draft PR. Are there any other keybinds I should add while I'm at it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants