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

Arrow keys don't work properly in emacs mode #6357

Closed
ax487 opened this issue Oct 15, 2017 · 2 comments
Closed

Arrow keys don't work properly in emacs mode #6357

ax487 opened this issue Oct 15, 2017 · 2 comments
Labels
Topic: bindkey Pull Request or issue regarding keyboard shortcuts

Comments

@ax487
Copy link

ax487 commented Oct 15, 2017

When using a vanilla oh-my-zsh installation, pushing left / right arrow move words forward / backward rather than characters. If I switch to vim keybindings using bindkey -v the issue disappears.

I added also bound the up/down keys using


bindkey "^[[A" history-beginning-search-backward # Up
bindkey "^[[B" history-beginning-search-forward # Down

This binding works in emacs mode but not in vim mode.

@mcornella mcornella added the Topic: bindkey Pull Request or issue regarding keyboard shortcuts label Apr 8, 2019
@ljluestc
Copy link

ljluestc commented Sep 5, 2023

To resolve the issue and ensure consistent behavior for keybindings in both modes, you can adjust your Zsh configuration with the following approach:

  1. Keybinding Mode Selection: First, you need to ensure that you're consistently using the same keybinding mode (either emacs or vim) for both arrow keys and other custom keybindings.

  2. Keybinding Customization: Depending on the keybinding mode you prefer (emacs or vim), customize the keybindings as needed.

For example, if you want to use emacs mode:

# Set Zsh to emacs keybinding mode
bindkey -e

# Customize keybindings (example with Up and Down arrow keys)
bindkey "^[[A" history-beginning-search-backward # Up
bindkey "^[[B" history-beginning-search-forward # Down

If you want to use vim mode:

# Set Zsh to vim keybinding mode
bindkey -v

# Customize keybindings (example with Up and Down arrow keys)
bindkey "^[[A" history-beginning-search-backward # Up
bindkey "^[[B" history-beginning-search-forward # Down
  1. Reload Your Shell Configuration: After making changes to your Zsh configuration file (usually ~/.zshrc), don't forget to reload your shell configuration for the changes to take effect:
source ~/.zshrc

By using either emacs or vim keybinding modes consistently, you can achieve the behavior you desire for arrow keys and other custom keybindings in your Zsh shell. Just make sure to choose the keybinding mode that suits your preferences.

@carlosala
Copy link
Member

Thanks for the response! Just a tiny detail: to reload zsh, it's recommended to run exec zsh or omz reload in case you are in omz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic: bindkey Pull Request or issue regarding keyboard shortcuts
Projects
Archived in project
Development

No branches or pull requests

4 participants