Code Monkey home page Code Monkey logo

evil-snipe's Introduction

evil-snipe

This is a new (and potentially buggy) plugin and I am an elisp newb -- any advice or contributions would be appreciated!

Snipe is a marriage of vim-sneak and vim-seek but for evil-mode on Emacs.

Put simply, evil-snipe is f/F/t/T on steroids. It can be configured to accept N characters, but by default will accept 2.

Installation

Evil-snipe can be installed from MELPA, via M-x package-install RET evil-snipe

Then, to enable globally, add the following to ~/.emacs:

(require 'evil-snipe)
(global-evil-snipe-mode 1)

;; Optional!
(evil-snipe-replace-evil) ;; replaces evil-mode's f/F/t/T/;/, with snipe
(evil-snipe-enable-nN)    ;; enable repeating with n/N (not implemented)

;; not necessary if using (evil-snipe-replace-evil)
(evil-snipe-enable-sS)    ;; enable repeating with s/S

Preview

<-- animated screenshot here soon -->

Features

  • s/S
    • |the abacus is => sab => the |abacus is
    • the abacus| is => Sab => the |abacus is
  • z/Z = inclusive, x/X = exclusive
    • |the abacus is => dzab => |acus is
    • the abacus| is => dZab => the | is
    • |the abacus is => dxab => |abacus is
    • the abacus| is => dXab => the ab| is
  • Snipe is always literal: s\* jumps to a literal \*
  • s<Enter>, S<Enter> (reverse), ; and , (reverse) jumps to the next match. Note: ; and , should still work directly after sniping even if you have rebound them.
  • Repeating with s/S can be enabled, see (evil-snipe-enable-sS).
  • Backspace to undo characters
  • TAB in the snipe prompt increments N on the fly. e.g. s<tab><tab>goal
  • Highlight matches if evil-snipe-enable-highlight
  • Incrementally highlight (as you type) if evil-snipe-enable-incremental-highlight
  • Change scope of searches with evil-snipe-scope
  • Change scope of searches while repeating with evil-snipe-repeat-scope (separate from evil-snipe-scope)
  • Change what the count prefix means to snipe with evil-snipe-count-scope
    • if nil, treat COUNT as default in vim: times-to-repeat
    • if 'letters, accept COUNT characters
    • if 'vertical, scope is column bound (vertical scoping)
  • Use (evil-snipe-replace-evil) to replace evil-mode's f/F/t/T/;/, with snipe. Snipe implements clever-f functionality as well.

Planned

  • Vertical-scoping: 5shi will jump to the next occurance of 'hi' that is within 5 columns of the cursor on any following line.
  • r/R operators for targeting remote objects (e.g. driwhi = delete remote inner word 'hi'), then return to starting point
  • p/P operators that do what r/R does, but stays in the modified location.
  • r/R/p/P text-objects, so: dirwo will delete the next inner word containing wo. dorwo will target the next OUTER word.
  • Repeating with n/N?

Configuration

  • Sniping in visual mode:

    (evil-define-key 'visual evil-snipe-mode-map "z" 'evil-snipe-f)
    (evil-define-key 'visual evil-snipe-mode-map "Z" 'evil-snipe-F)
  • Snipe disables evil-mode's substitute commands (s/S). To prevent this, set evil-snipe-auto-disable-substitute to nil (before evil-snipe is loaded).

  • To change the highlight colors, configure: evil-snipe-first-match-face and evil-snipe-matches-face

  • Disable N> prompt when sniping by setting evil-snipe-show-prompt to nil

Configure like vim-seek

(setq evil-snipe-scope 'line)
(setq evil-snipe-repeat-scope 'whole-line)
(setq evil-snipe-count-scope nil)
(setq evil-snipe-search-highlight nil)
(setq evil-snipe-search-incremental-highlight nil)
(setq evil-snipe-enable-half-cursor nil)

Configure like vim-sneak

(evil-snipe-enable-sS)

;; or 'buffer, 'whole-visible or 'whole-buffer
(setq evil-snipe-scope 'visible)
(setq evil-snipe-repeat-scope 'whole-visible)

(setq evil-snipe-count-scope 'vertical)  ;; not implemented yet
(setq evil-snipe-enable-highlight t)
(setq evil-snipe-enable-incremental-highlight t)
(setq evil-snipe-enable-half-cursor nil)

Compatibility

  • evil-surround does not conflict with evil-snipe. Surround uses s/S in visual mode and s in operator mode. Snipe uses s/S in normal mode and z/Z/x/X in operator mode.
  • evil-space needs more investigating.

Credits

Evil-snipe was inspired by:

evil-snipe's People

Contributors

hlissner avatar troyp avatar

Watchers

James Cloos avatar  avatar  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.