Giter VIP home page Giter VIP logo

evil-snipe's Introduction

Made with Doom Emacs Release tag MELPA Build status

evil-snipe

Sniper!

Evil-snipe emulates vim-seek and/or vim-sneak in evil-mode.

It provides 2-character motions for quickly (and more accurately) jumping around text, compared to evil's built-in f/F/t/T motions, incrementally highlighting candidate targets as you type.

Install

Evil-snipe is available on MELPA.

M-x package-install evil-snipe

(require 'evil-snipe)

evil-snipe comes with two global modes: evil-snipe-mode and evil-snipe-override-mode, and two local modes: evil-snipe-local-mode and evil-snipe-override-local-mode.

You can either a) enable one or both globally:

(evil-snipe-mode +1)
(evil-snipe-override-mode +1)

;; and disable in specific modes
(push 'python-mode evil-snipe-disabled-modes)

;; or disable it manually
(add-hook 'python-mode-hook #'turn-off-evil-snipe-mode)
(add-hook 'python-mode-hook #'turn-off-evil-snipe-override-mode)

Or b) enable one or both locally, where you need it:

(add-hook 'python-mode-hook 'turn-on-evil-snipe-mode)
(add-hook 'python-mode-hook 'turn-on-evil-snipe-override-local-mode)

Usage

By default, snipe only binds s (forward)/S (backward) to evil-snipe-s and evil-snipe-S, respectively. In operator mode, snipe is bound to z/Z and x/X (exclusive).

The last snipe can be repeated with s/S after a successful snipe (or with s+RET).

Evil-snipe can override evil-mode's native motions with 1-char sniping:

;; Globally
(evil-snipe-override-mode 1)

;; Or locally
(add-hook 'ruby-mode-hook 'evil-snipe-override-local-mode)

The benefit of this is:

  • Incremental highlighting
  • You can repeat searches with f, F, t and T (ala Clever-F)
  • ; and , are available for repeating searches (and won't interfere with the original maps; they take effect only after a successful snipe)
  • A more streamlined experience in general

Customization

Search scope

These three variables determine the scope of snipes (and the incremental highlighter):

  • evil-snipe-scope (default: line)
  • evil-snipe-repeat-scope (default: whole-line) Scope while repeating searches with evil-snipe-repeat or evil-snipe-repeat-reverse.
  • evil-snipe-spillover-scope (default: nil) Scope to expand to when a snipe fails. Only useful if set to a broader scope than evil-snipe-scope.

These are the possible settings:

Value Description
'line rest of the current line after cursor (vim-seek behavior)
'buffer rest of the buffer after cursor (vim-sneak behavior)
'visible the rest of the visible buffer after cursor
'whole-line same as 'line, but highlights on either side of cursor
'whole-buffer same as 'buffer, but highlights all matches in buffer
'whole-visible same as 'visible, but highlights all visible matches in buffer

Character aliases

Specific characters can be aliased to regex patterns by modifying evil-snipe-aliases.

Examples

  • To map [ to any opening parentheses or bracket in all modes:

    (push '(?\[ "[[{(]") evil-snipe-aliases)

    Therefore, sa[ will match a[, a{ or a(

  • To map : to a python function (but only in python-mode):

    (add-hook 'python-mode-hook
      (lambda ()
        (make-variable-buffer-local 'evil-snipe-aliases)
        (push '(?: "def .+:") evil-snipe-aliases)))

Faces

  • evil-snipe-first-match-face: The first highlighted match.
  • evil-snipe-matches-face: The rest of the highlighted matches.

Sniping in visual mode

To avoid binding conflicts, evil-snipe has no visual mode bindings. You can add them with:

(evil-define-key 'visual evil-snipe-local-mode-map "z" 'evil-snipe-s)
(evil-define-key 'visual evil-snipe-local-mode-map "Z" 'evil-snipe-S)

Integration into avy/evil-easymotion

This will allow you to quickly hop into avy/evil-easymotion right after a snipe.

(define-key evil-snipe-parent-transient-map (kbd "C-;")
  (evilem-create 'evil-snipe-repeat
                 :bind ((evil-snipe-scope 'buffer)
                        (evil-snipe-enable-highlight)
                        (evil-snipe-enable-incremental-highlight))))

(Thanks to PythonNut for this. More info here)

Conflicts with other plugins

It seems evil-snipe-override-mode causes problems in Magit buffers, to fix this:

(add-hook 'magit-mode-hook 'turn-off-evil-snipe-override-mode)

Appendix

Other settings

  • evil-snipe-enable-highlight (default: t) Highlight first match.
  • evil-snipe-enable-incremental-highlight (default: t) Incrementally highlight all matches in scope.
  • evil-snipe-override-evil-repeat-keys (default: t) Whether or not evil-snipe will override evil's default ; and , mappings with snipe's (when evil-snipe-override-mode is on).
  • evil-snipe-repeat-keys (default t) If non-nil, pressing s/S after a search will repeat it. If evil-snipe-override-evil is non-nil, this applies to f/F/t/T as well.
  • evil-snipe-show-prompt (default t) Whether or not to show the "N>" prompt.
  • evil-snipe-smart-case (default nil) If non-nil, searches will be case-insenstive unless your search contains a capital letter.
  • evil-snipe-auto-scroll (default nil) If non-nil, the window will scroll to follow the cursor.
  • evil-snipe-auto-disable-substitute (default: t) Whether or not evil's default substitute mappings (s/S) are unset. They can sometimes interfere with snipe. Must be set before evil-snipe is loaded.
  • evil-snipe-skip-leading-whitespace (default t) If non-nil, sniping will skip over leading whitespace when you search for whitespace.
  • evil-snipe-tab-increment (default nil) If non-nil, pressing TAB in the snipe prompt will increase the size of the snipe buffer.
  • evil-snipe-use-vim-sneak-bindings (default nil) If non-nil, evil-snipe binds z/Z to exclusive sniping in operator state, but leaves the x/X bindings free. This mirrors the default bindings of vim-sneak, and frees up cx/cX to be used by evil-exchange.

Functions

  • evil-snipe-mode / evil-snipe-local-mode
  • evil-snipe-override-mode / evil-snipe-override-local-mode
  • evil-snipe-repeat / evil-snipe-repeat-reverse
  • evil-snipe-s / evil-snipe-S: inclusive 2-char sniping
  • evil-snipe-x / evil-snipe-X: exclusive 2-char sniping
  • evil-snipe-f / evil-snipe-F: inclusive 1-char sniping
  • evil-snipe-t / evil-snipe-T: exclusive 1-char sniping

Default keybindings

(evil-define-key '(normal motion) evil-snipe-local-mode-map
  "s" 'evil-snipe-s
  "S" 'evil-snipe-S)

(evil-define-key 'operator evil-snipe-local-mode-map
  "z" 'evil-snipe-s
  "Z" 'evil-snipe-S
  "x" 'evil-snipe-x
  "X" 'evil-snipe-X)

(evil-define-key 'motion evil-snipe-override-local-mode-map
  "f" 'evil-snipe-f
  "F" 'evil-snipe-F
  "t" 'evil-snipe-t
  "T" 'evil-snipe-T)

(when evil-snipe-override-evil-repeat-keys
  (evil-define-key 'motion map
    ";" 'evil-snipe-repeat
    "," 'evil-snipe-repeat-reverse))

evil-snipe's People

Contributors

ayyess avatar celeritascelery avatar daanturo avatar dvzubarev avatar endrebak avatar gabesoft avatar galagora avatar hlissner avatar itsliamegan avatar justbur avatar kenranunderscore avatar ml729 avatar noctuid avatar thebb avatar troyp avatar wbolster-eiq avatar yunhao94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

evil-snipe's Issues

evil-snipe--interactive: Symbol's value as variable is void: keys

Hi,

I just upgraded evil-snipe via Melpa and every time I invoke it I get the following error message:

evil-snipe--interactive: Symbol's value as variable is void: keys

I'm using use-package to configure my packages and have the following in my config

            (use-package evil-snipe
              :ensure t
              :config (progn
                        (global-evil-snipe-mode 1)))))

I'm on GNU Emacs 25.0.50.1 (x86_64-apple-darwin14.1.0, NS appkit-1344.72 Version 10.10.2 (Build 14C109)) of 2015-01-31

If you need more information just let me know.

Better docs?

Would you be interested in a PR with an explanation of evil-snipe? I imagine that the images are kinda hard to understand, and that some visitors that aren't going to spend more than two secs to read the page and not understand anything and leave.

I feel that one of the first things on the page should be something like "what can evil-snipe do for me?", like I wrote for the spacemacs contrib layer: https://github.com/syl20bnr/spacemacs/tree/master/contrib/evil-snipe#description but more thorough.

Please add a prefix to test-helper.el to avoid conflicts with 68 other packages

There exist at least 69 packages that contain a file named test-helper.el that also provides the feature test-helper.

This leads to issues for users who have at least two of these packages installed. It is unlikely that such a user would be able to run the tests of all of those packages. If the primary test file of one of those packages does (require 'test-helper), then it is undefined which of the various test-helper.el files gets loaded. Which it is, depends on the order of the load-path.

To avoid this conflicts, you should rename your test-helper.el to <your-package>-test-helper.el and adjust the feature accordingly.

Also don't forget to update the require form in your primary test file and/or update references to the library/feature elsewhere. Also, if your primary test file is named something like test.el, then please consider renaming that too (same for any other utility elisp files your repositoroy may contain).

Thanks!

PS: This issue is a bit generic because I had to open 69 issues.

`advice-add` breaks Emacs 23.x

evil-snipe uses the new advice-add and advice-remove, without checking whether they are bound. Since they are not present in Emacs <24.4, this version of Emacs breaks when using global-evil-snipe-mode. Once the global mode is activated, all kinds of actions, like switching buffers, using help, executing lisp and executing external commands fail with the message :

Error in post-command-hook (global-evil-snipe-mode-check-buffers): (void-function advice-add). 

(I'd fix it, but I'm not familiar with the advice system and I'd probably just introduce another bug.)
(edit: s/23.x/<24.4/g)

Repeat `t/T` with `f/F`?

t/T are more clunky to reach than f/F so it would be nice to be able to repeat t/T with f/F.

This could be an option, but why not just make it the default? If you are using t<char> followed by f<char> you are doing something wrong, so making f/F a special key after t/T should be safe.

Abort via C-g

Hi,
please consider adding one more char-equal branch to exit evil-snipe via C-g. I find it easier to reach than esc.
thanks,
Sebastian

no clean way to use different keys for snipe commands

hi, first of all, evil-snipe is fantastic. thanks.

that said, i am having some trouble making it work with different keys. i use the colemak keyboard layout, and use evil-colemak-basics to use different keys for various evil commands.

recently i decided to also move the functionality for f and t to different keys for improved ergonomics and preserved muscle memory. in short, i want t to jump forwards, and j to jump backwards. with colemak, keys are at a different location, and t and j fit in my hybrid qwerty/colemak keybinding scheme for non-insert states); details here.

this works fine for evil's built-in evil-find-char-* commands. however, i want to use evil-snipe to spice up f and t. at first i thought all that was needed would be binding evil-snipe-f and friends to the appropriate keys. i do not use evil-snipe-override-mode since that does not use the keys i want, but with a few key mappings the result will be the same.

it turns out this works fine for triggering evil-snipe, but repeating a snipe fails. the reason is that the transient keymap hardcodes the key bindings "f" (forward) and "t" (backward) in the evil-snipe-def macro.

i managed to get it working using this code:

(evil-snipe-def 1 inclusive "t" "T")
(evil-snipe-def 1 exclusive "j" "J")
(evil-define-key '(motion normal visual) keymap
  "t" 'evil-snipe-t
  "T" 'evil-snipe-T
  "j" 'evil-snipe-j
  "J" 'evil-snipe-J)

...but i am not very happy about it:

  • it uses a private evil-snipe macro
  • it replaces the standard evil-snipe-t command

perhaps there is a better way to get this working? perhaps (this-command-keys) can be used instead of hardcoding the keys?

hopefully i made the issue clear. ideas and discussion more than welcome. 🌷

[feature] Operating on incrementally extended regions

Okay, evil-snipe is super cool because it lets you think: okay, I want to jump to that z over there, so fz. Oh, I'm not there yet? I'll just mash f until I am. This is great because I have to worry less about those pesky letters that always seem to creep up between my point and target.

At the moment this doesn't extend to using motions as the ranges for an operator. dfz does work, of course, but if you missed that other z (the one sneaking between your point and your goal) then you're left having deleted less than you intended. This time, though, f won't save you. It'll search, but it won't extend the deletion.

I'm not entirely sure how to go around this.

One simple way to solve this would be to simply undo the last operation and redo a new operation on the extended region, potentially in an invisible buffer so it doesn't jar the UI. The only caveat is that not all operations can be undone.

Another way would be to delay the operation until after the transient map terminates: df f f f Up now the deletion is done. Of course, this sort of violates the vim timing paradigm, so that's not a perfect solution either.

You could just repeat the whole operation. That's pretty clean and side effect free, so long as you don't mind ("the cz" "the czechoslovakian food is amaz" "the czechoslovakian food is amazing z" ...) in your kill-ring. (I wouldn't mind too much, but maybe other people would)

A (hardly comprehensive) list of solutions to a problem that maybe doesn't even deserve solving

What do you think?

make binding s configurable

the s and S binds override the standard evil/vim substitute command, which my fingers rely on, so i manually disable those in my config like this:

  (evil-define-key* '(motion normal) evil-snipe-local-mode-map
    "s" nil
    "S" nil)

i recently had to change my config after an evil-snipe upgrade since the map name changed.

this got me wondering why overriding behaviour is non-optional?

(defvar evil-snipe-local-mode-map
  (let ((map (make-sparse-keymap)))
    (evil-define-key* '(normal motion) map
      "s" #'evil-snipe-s
      "S" #'evil-snipe-S)
    (if evil-snipe-use-vim-sneak-bindings
        (evil-define-key* 'operator map
          "z" #'evil-snipe-x
          "Z" #'evil-snipe-X)
      (evil-define-key* 'operator map
        "z" #'evil-snipe-s
        "Z" #'evil-snipe-S
        "x" #'evil-snipe-x
        "X" #'evil-snipe-X))
    map))

is the current map definition. a (when ...) around that part and a defcustom for it would work i think?

an alternative would be to not use the minor modes at all, but that would mean i have to bind everything myself.

what do you think makes most sense?

evil-snipe-disabled-modes seems not working by default

(require 'evil-snipe)
*** Eval error ***  Symbol’s function definition is void: org-agenda-mode

If I load org-agenda and the function org-agenda-mode can be run, it will put an other error for magit-mode which I have required when emacs init.

The whole log in ielm.

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (require 'evil-snipe)
*** Eval error ***  Symbol’s function definition is void: org-agenda-mode
ELISP> (require 'org-agenda)
org-agenda
ELISP> (fboundp 'org-agenda-mode)
t
ELISP> (require 'evil-snipe)
*** Eval error ***  Symbol’s value as variable is void: magit-mode
ELISP> (fboundp 'magit-mode)
t

Smartcase support?

Thanks for a great package. Evil-snipe is a must-have.

One thing I am missing though is smartcase, which is a brilliant vim feature.

It is simply

if a pattern contains an uppercase letter, it is case sensitive, otherwise, it is not. 
For example, /The would find only "The", while /the would find "the" or "The" etc. 

It would be nice to have smartcase searches with s (as an option at least). f and t are probably better cased.

User-defined regexes?

This is slightly related to the idea of symbol groups #10 . Another idea might be to have a char for regexes, for example æ, the key to the left of the right pinky. Then the key coming after the æ would stand for a user defined regex.

I would use it like this: sæf to search with the regex (defined by me in a dotfile) ^def \w+):.

This way I could quickly find all python function definitions with sæfsss (I always forget the function names). Another one could be sæp to find @property, etc.

I would probably create a different regex map for the different language modes.

This is probably more of a poweruser feature, but just throwing it out there. You could even have a crowd-configured library of useful regexes like yasnippet.

Freezes in a large Org file

evil-snipe works fine for me in normal code files/small Org files. However when I try to perform a s/S search in a very large Org file which contains over 10000 lines, Emacs simply freezes and I had to press C-g to get out of it. Any idea what happened and how I might debug it? This is observed using Spacemacs on Windows. I'm yet to test it on Ubuntu.

System Info 💻

  • OS: windows-nt
  • Emacs: 24.5.1
  • Spacemacs: 0.105.22
  • Spacemacs branch: develop (rev. 64a0cc2)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(auto-completion better-defaults spell-checking syntax-checking semantic chrome search-engine typography games restclient colors eyebrowse themes-megapack gtags vim-powerline evil-snipe unimpaired fsharp emacs-lisp haskell org markdown html yaml shell-scripts javascript c-c++)

Moving mouse ends evil-snipe search

Hi, I'm finding evil-snipe invaluable during my day to day programming. However, one continued problem I keep running into is the fact that moving the mouse at all will end the current search and pressing 's' will start a new one instead of cycling through the next occurances.

This is a problem for me as I bump my trackpad frequently while I'm working and the minute mouse movement frequently ends the search for me prematurely resulting in a new accidental search for 'ss'. Is there any way for evil-snipe to ignore mouse movement or disable this behavior?

I am using Spacemacs with the evil-snipe layer enabled. Thank you!

turning off evil-snipe mode does it globally

calling turn-off-evil-snipe-mode turns off the mode globally.
The documentation claims that it only disables the mode in the current buffer.

Spacemacs would need an option for turning evil-snipe of on a per-buffer basis. Would this be possible?

Prevent rebinding `s` in Info-mode

When I enable evil-snipe and then C-h i, I find that info's usual s binding to search now starts evil-snipe instead. I want to keep the old binding in that mode.

I'm not able to work around that using Info-mode-hook to call turn-off-evil-snipe-override-mode and/or turn-off-evil-snipe-mode either. However, using those functions interactively after entering info, I can use the s binding again.

Can you provide some way to keep that old binding?

I was able to reproduce this using emacs 25.1 and no configuration other than basically pointing emacs at where my elpa packages is on disk, then enabling evil and evil-snipe.

Enhance snipe jumplist interaction

from sneak.vim README:

Press ctrl-o or to go back to the starting point. This is a built-in Vim motion; Sneak adds to Vim's jumplist only on s invocation—not repeats—so you can abandon a trail of ; or , by a single ctrl-o or.

Can we get this behaviour by leaving :jump t under evil-snipe-def, and setting :jump nil on evil-snipe-repeat and its reverse? After this discussion, I realised that pushing to the jumplist after every small jump is not how vim does it by default either.

edit: maybe making this customisable would be better so those who prefer the current behaviour, or even no jumplist at all can have their way.

Wrongly highlights targets with letters reversed

For example, if I snipe for fi, occurrences of if in buffer also get highlighted, though they do not get jumped to.

Can be reproduced with (some may not be necessary):

(setq evil-snipe-scope 'buffer
        evil-snipe-repeat-scope 'buffer
        evil-snipe-enable-highlight t
        evil-snipe-enable-incremental-highlight t
        evil-snipe-auto-disable-substitute t
        evil-snipe-show-prompt t
        evil-snipe-smart-case t
        evil-snipe-repeat-keys nil)

Invalid function (quote line)

I'm getting an error message saying Invalid function: (quote line) on GNU Emacs 25.0.50.1 (x86_64-apple-darwin14.0.0, NS appkit-1343.16 Version 10.10.1 (Build 14B25)). Changing case in line 180 of evil-snipe.el to cl-case seems to fix this.
thanks,
Sebastian

Symbol groups?

It would be neat to be able to define that some symbols, i.e. the easy to reach ø (under the right pinky, dunno what it is in the US) could be redefined to mean a class of symbols, i.e. (){}<>.;:_--.

This way saø would match both a. and a{.

I do not know of this feature in any other vim-sneak alike, so it would put it ahead of the pack. Should probably not be too hard to implement either, must be doable with regexes and perhaps a macro.

Repeat operations leaking through

Could you please look into repeat operations "leaking through" into insert mode (a teensy bug).

Pressing c t r and then t (to type the letter t in insert mode) makes evil-snipe jumps to the next instance of r instead.

Note that something similar to this might be a feature, not a bug. If you meant to clear to amaz, but only got to czechoslovakian being able to press t again is a good thing.

(But this leads to inconsistent behavior if you meant to type the letter t. You could add a timeout so that t means repeat clear until 0.2 seconds for example, but this is a tiny thing not worth bothering with unless you want to. I think syl20bnr implemented a timeout in avy which might be worth looking at.)

Problem with aliases

Hi, I have emacs 24.5.1, with installed evil and evil-snipe.
I sequentially evaled following expressions in scratch buffer.

(evil-mode)
(setq evil-snipe-scope 'buffer)
(evil-snipe-override-mode 1)
(evil-snipe-mode 1)
(evil-snipe-add-alias ?\[ "[[{(]")

Then I press f[ and '(' are highlighted, it is OK.
After creating new file with some text "(test { test)", the defined alias is not working, i.e. { or ( are not highlighted and I can not jump to them by hitting f[.
The output of M-x describe-key is evil-snipe-f though.

snipe-repeat only repeat in line

when evil-snipe-scope is set 'visible other than default 'line
evil-snipe-repeat only jumps within current line. It won't jumpt to the matches in the following lines.

Maybe the scope variable is not referenced in snipe-repeat?

Cheers,

Binding `S` is undefined

Disclaimer: I'm somewhat of an emacs noob.

With regards to evil-snipe I have just this:

(use-package evil-snipe
  :ensure t
  :config
  (setq  evil-snipe-scope 'whole-visible))

When I restart emacs, S is undefined, instead of evil's evil-change-whole-line. Shouldn't evil-snipe only rebind the key if the mode is enabled? I want the native evil functionality.

P.S. What I'm trying to achieve is this: I want to use just evil-snipe's multi-line ftFT and repeat search functionality with ftFT (so nothing else--no rebinding of any keys except ftFT to repeat the searches) because I'm already using avy. I know the above settings do not accomplish this yet, but that isn't the issue. Do I need to rebind all evil-snipe bindings to the defaults or can I disable all the bindings or something?

jump to next/prev match not working

I press s, type 2 chars, then pressing s/S/;/, and it's not working.
In *Messages* buffer: evil-snipe-repeat: Symbol's function definition is void: first.

Related configuration:

(require 'evil-snipe)
(global-evil-snipe-mode 1)
(setq evil-snipe-repeat-keys t)
(setq evil-snipe-scope 'visible)
(setq evil-snipe-repeat-scope 'whole-visible)
(setq evil-snipe-enable-highlight t)
(setq evil-snipe-enable-incremental-highlight t)

disabling evil-snipe-override-mode

Thanks for evil-snipe!
if using evil-snipe-override-mode disabling hooks don't work.

In particular the following code does NOT disable evil-snipe mode in ranger

(evil-snipe-override-mode 1)
(add-hook 'ranger-mode-hook 'turn-off-evil-snipe-override-mode)

but using "normal" evil-snipe DOES

(evil-snipe-mode 1)
(add-hook 'ranger-mode-hook 'turn-off-evil-snipe-mode)

evil snipe conflicts with several ranger-mode keybindings, particularly ; which is bound to the ranger-dired-map. How do I disable evil-snipe-override-mode in ranger?

Snipe repeat not working when key is rebound

When changing the key-bindings of f and t the repeat feature does not rebind. Also,
(evil-snipe-def 1 inclusive "f" "F")
(evil-snipe-def 1 exclusive "t" "T")
does not fix this for me.

Add Option to Use Jump Characters

I think it would be awesome if evil-snipe had jump characters like sneak's streak mode (or like avy, easymotion, etc.). This is the one thing I'm really missing from sneak. For example, if there are more than 2 matches, the start of each match is highlighted with a home row key (or from user defined keys), and pressing that key moves the point directly to the match. If there are more matches then defined keys, each match is highlighted with multiple letters/keys.

Make evil-snipe-replace-evil a bool/var?

I created a pull request for an evil-snipe contribution layer in Spacemacs (their tagline should be "vim done right"): syl20bnr/spacemacs#712

To make evil-snipe integrate better with Spacemacs, it would be nice if (evil-snipe-replace-evil) could be set/unset like a regular variable. Then replace-evil could be the default in the evil-snipe layer, but users would be able to turn it off in their .spacemacs-file.

If my talk of layers is confusing you, please see: https://github.com/syl20bnr/spacemacs#configuration-layers

Possible to support char-fold-to-regexp option like search-default-mode?

With the release of 25.1, there is a new option for isearch to search not only for literal characters, but ASCII equivalents. It would be nice if snipe searches can support this.

'isearch' and 'query-replace' can now perform character folding in matches.
This is analogous to case folding, but instead of disregarding case
variants, it disregards wider classes of distinctions between similar
characters.  (Case folding is a special case of character folding.)
This means many characters in the search string will match entire
groups of characters instead of just themselves.

For instance, the ASCII double quote character " will match all
variants of double quotes, and the letter 'a' will match all of its
accented cousins, even those composed of multiple characters, as well
as many other symbols like U+249C (PARENTHESIZED LATIN SMALL LETTER
A).

Character folding is enabled by customizing 'search-default-mode' to
the value 'char-fold-to-regexp'.  You can also toggle character
folding in the middle of a search by typing 'M-s ''.

'query-replace' honors character folding if the new variable
'replace-char-fold' is customized to a non-nil value.

Use snipe as a movement?

This might be a lot of work, but it would be nice to be able do something like dsli to delete until li.

evil-snipe-repeat-keys nil should work with override mode

First, thanks for the essential package. It's even better than the vim inspiration.

What is especially nice is the transient mappings to ; and , while sniping. This allows , for example, to be bound to something else normally, and still be used for search repeat. I also want this behaviour for f/t, so I set (evil-snipe-override-mode 1). However, I want s/f/t to always start a new search, rather than repeating the search (I already have ; and , for that). (setq evil-snipe-repeat-keys nil) seems to be the right setting, but with override-mode enabled, s/f/t are bound to repeat the search.

So to reproduce: (setq evil-snipe-repeat-keys nil) (evil-snipe-override-mode 1), try a search with s, then press s again. The desired behaviour is that you will be prompted for 2 new letters to snipe to, not that the search will be repeated. Currently, you need to exit the transient state with esc then search again, adding an unnecessary step.

error on turning off mode

When I have mode enabled and execute evil-snipe-mode, I get this error:
turn-off-evil-snipe-mode: Wrong number of arguments: (2 . 2), 3

How binding keys with evil-snipe

I would like to bind the keys f and <F9>, without affecting the other Evil operations.
So I have the following snippet in my configuration:

(define-key evil-normal-state-map (kbd "f <f9>") 'foobar)

So I press f and F9, then foobar will be called.
However, now I'm facing another problem. The f-key is not functioning anymore for other Evil operations. It works only for ff9 and not for finding character a with fa.
To circumvent this, I use the following workaround.

(defun my-evil-find-char (arg char)
    (interactive (list (prefix-numeric-value current-prefix-arg) (read-key)))
    (cond
    ((characterp char)
        (evil-find-char arg char))
    ((eq char 'f9)
        (foobar))
    (t
        (user-error "Unknown key combination"))))

(define-key evil-motion-state-map (kbd "f") 'my-evil-find-char)

So if there is no f9 key passed, he will pass the other characters to f.
This works so far. However, with Evil Snipe I'm facing an another issue. When pressing fF9, I got the following error:

evil-snipe--process-key: Wrong type argument: stringp, f9

Any suggestion to work around this?

Failed to jump to the last character in a buffer

Hi,
I use emacs-25.1.2 on Ubuntu 16.04
Steps to reproduce:

  1. M-x evil-mode
  2. eval in scratch buffer
(evil-snipe-override-mode 1)
(setq evil-snipe-scope 'whole-visible)
  1. Then try to jump to the last character in the buffer press f) and then f multiple times.
  2. Cursor is in the end of the first line "...mode 1)|"

I expect that cursor will be in the end of the second line "...whole-visible)|"

Allow for customization of repeat keys

I am using Spacemacs, and here the default search keys are n and N. I am using this workaround in the meantime:

  (setq evil-snipe-override-local-mode-map
    (let ((map (make-sparse-keymap)))
      (evil-define-key* 'motion map
                        "f" #'evil-snipe-f
                        "F" #'evil-snipe-F
                        "t" #'evil-snipe-t
                        "T" #'evil-snipe-T)
      (when evil-snipe-override-evil-repeat-keys
        (evil-define-key* 'motion map
                          "n" #'evil-snipe-repeat
                          "N" #'evil-snipe-repeat-reverse))
      map))

  (setq evil-snipe-parent-transient-map
    (let ((map (make-sparse-keymap)))
      (define-key map "n" #'evil-snipe-repeat)
      (define-key map "N" #'evil-snipe-repeat-reverse)
      map))

Is this workaround safe, BTW? I load it in my init.el, and it works.

update keymap name in readme

I've just updated to the latest version on melpa/github, and found my configs using evil-snipe-mode-map no longer works. After taking a look at the source code I changed the name to evil-snipe-local-mode-map and everything worked fine again. But it confused me for a few minutes.

It would be nice for you to change the name in readme in case a new user come to read it.

evil-snipe-scope 'visible matches in non-visible parts

When setting evil-snipe-scope to 'visible it will also match folded/invisible parts as long as they are part of the "visible" buffer. E.g. in org mode it will match in hidden sub-trees as long as the folded headline is in the visible part of the buffer. Is this intended?

evil-substitute is active in new buffers

evil-substitute is active in buffers with the fundamental major mode, even though I have set the auto-disable to 't. Calling the function evil-snipe-local-mode enables evil-snipe in that buffer.

Keep current snipe when can't find further chars

Currently I'm using evil-snipe a la Clever-F, and it works as intended. The only thing I noticed is that if I land on the last occurrence and hit 'f' again while on it, I'll get a message saying "Can't find char" and I'll lose the current snipe and I'll have to reinput the snipe again, in the reverse direction. Is there anyway to change this behavior? If you need clarification, I can give examples.

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.