back

Published on

Zsh Keybindings Plugin

Zsh Keybindings Plugin

zsh vim emacs terminal productivity

Enhance your terminal experience with the Zsh Keybindings Plugin, which combines Vim’s modal editing power with Emacs keybindings in insert mode. This plugin makes your terminal experience more efficient by combining the modal editing power of Vim with the convenience of familiar Emacs navigation commands.

Please give a star to the repository if you like the plugin!

Installation Methods

Choose your preferred plugin manager:

# Using Zap (Preferred)
plug "sadiksaifi/zsh-keybindings"

# Using Zinit
zinit light sadiksaifi/zsh-keybindings

# Using Oh-My-Zsh
git clone https://github.com/sadiksaifi/zsh-keybindings.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-keybindings
# Then add zsh-keybindings to your plugins array in .zshrc

# Manual installation
git clone https://github.com/sadiksaifi/zsh-keybindings.git
# Then add to your .zshrc:
source /path/to/zsh-keybindings/zsh-keybindings.zsh

Key Features

Vim Mode with Visual Indicators

The plugin sets Vim keybindings as default with cursor appearance changes based on mode:

  • Insert mode: Beam cursor (|)
  • Command mode: Block cursor ()

This visual distinction helps you immediately identify which mode you’re in.

Advanced Text Objects

Gain access to text objects for quotes and brackets in visual and operator-pending modes:

i', a'   - Inner/around single quotes
i", a"   - Inner/around double quotes
i`, a`   - Inner/around backticks
i(, a(   - Inner/around parentheses
i[, a[   - Inner/around square brackets
i{, a{   - Inner/around curly braces
i<, a<   - Inner/around angle brackets
ib, ab   - Inner/around block characters

Emacs Keybindings in Insert Mode

Use familiar Emacs shortcuts when in insert mode:

Ctrl+A - Move to beginning of line
Ctrl+E - Move to end of line
Ctrl+P - Previous history item
Ctrl+N - Next history item
Ctrl+B - Move backward one character
Ctrl+F - Move forward one character
Ctrl+D - Delete character under cursor
Ctrl+K - Kill text to end of line
Ctrl+U - Kill text to beginning of line
Ctrl+W - Kill word backward
Ctrl+Y - Yank previously killed text

Enhanced Navigation

The plugin provides improved navigation capabilities:

Home      - Go to beginning of line
End       - Go to end of line
PageUp    - Scroll up through history
PageDown  - Scroll down through history
Ctrl+←    - Move backward one word
Ctrl+→    - Move forward one word

Navigate completion menus with ease:

Tab       - Complete and show menu
Shift+Tab - Complete backward in menu
Ctrl+J    - Move down in completion menu
Ctrl+K    - Move up in completion menu
Ctrl+H    - Move left in completion menu
Ctrl+L    - Move right in completion menu

Why Use This Plugin?

  1. Improved Efficiency: Combine the precision of Vim’s modal editing with the accessibility of Emacs commands
  2. No Context Switching: Use the same keybindings for text manipulation across different contexts
  3. Visual Feedback: Understand your current mode at a glance with cursor shape changes
  4. Enhanced Completion: Navigate complex completion menus with intuitive keyboard shortcuts
  5. Modern Terminal Support: Designed to work with contemporary terminal emulators

Customization

While the plugin comes with sensible defaults, you can customize it by adding your own keybindings in your .zshrc file after loading the plugin.

For more information and to contribute to the project, visit the GitHub repository.