Giter Site home page Giter Site logo

zsh-easy-motion's Introduction

Vim's easy-motion for zsh

Demo

zsh-easy-motion demo

Introduction

This plugin brings Vim's easy-motion plugin to zsh. It is inspired by zce.zsh. Unfortunately, zce.zsh only supports the seek operation of easy-motion so I have started my own implementation that adds much more easy-motion movements. Currently, the following motions are supported: b, B, w, W, e, E, ge, gE, j, J, k, K f, F, t, T, c (camelCase).

Requirements

This plugin needs Python 2.7 or 3.3+. You can check your installed Python version with

python --version

If you are running a recent Linux distribution or macOS, an appropriate Python version should already be installed.

Installation

Using zplug

  1. Add zplug "IngoMeyer441/zsh-easy-motion" to your .zshrc.

  2. Bind a prefix key for easy-motion in vicmd mode, for example the space key:

    bindkey -M vicmd ' ' vi-easy-motion

Manual

  1. Clone this repository and source easy_motion.plugin.zsh in your .zshrc

  2. Bind a prefix key for easy-motion in vicmd mode, for example the space key:

    bindkey -M vicmd ' ' vi-easy-motion

Usage

Press the configured prefix key (for example space) in vi command mode and enter a vi motion command. Possible jump targets are highlighted by red letters. Press one of the highlighted letters to jump to the corresponding position directly.

This plugin also works in operator-pending mode.

Grouping

If more jump targets exist than configured target keys, targets will be grouped and a second key press is needed to determine the jump target (see the demo for an example). Groups always contain a preview of the next key which is needed to reach the target position. The grouping works exactly like the grouping mechanism in Vim's easymotion plugin.

The grouping algorithm works recursively, so grouping is repeated if necessary. However, that case should only occur if a small set of target keys was configured.

Configuration

Target keys

The target keys can be configured with the EASY_MOTION_TARGET_KEYS environment variable. The default is taken from the Vim default configuration value:

EASY_MOTION_TARGET_KEYS="asdghklqwertyuiopzxcvbnmfj;"

You can configure as many keys as you want (minimum two keys).

Colors

The color of dimmed and highlighted text can be configured by setting four environment variables. These are the default settings:

EASY_MOTION_DIM="fg=242"
EASY_MOTION_HIGHLIGHT="fg=196,bold"
EASY_MOTION_HIGHLIGHT_2_FIRST="fg=11,bold"
EASY_MOTION_HIGHLIGHT_2_SECOND="fg=3,bold"

These settings were used in the demo:

EASY_MOTION_DIM="fg=242"
EASY_MOTION_HIGHLIGHT="fg=196,bold"
EASY_MOTION_HIGHLIGHT_2_FIRST="fg=#ffb400,bold"
EASY_MOTION_HIGHLIGHT_2_SECOND="fg=#b98300,bold"

Visit the zsh docs for a description of possible highlights and http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html for a listing of possible color codes.

Other plugins

If you like this plugin and use tmux, please also try my tmux easy-motion port: tmux-easy-motion.

zsh-easy-motion's People

Contributors

ingomeyer441 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.