From 3ee86b118381815e718258bc5028c91706767d7e Mon Sep 17 00:00:00 2001 From: Endre Bakken Stovner Date: Tue, 3 Mar 2015 19:09:44 +0100 Subject: [PATCH] Updated readme for evil-snipe layer, plus minor codechange --- contrib/evil-snipe/README.md | 32 +++++++++++++++++++++++++++++--- contrib/evil-snipe/packages.el | 6 +++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/contrib/evil-snipe/README.md b/contrib/evil-snipe/README.md index 9c60db79f..b9070f0b0 100644 --- a/contrib/evil-snipe/README.md +++ b/contrib/evil-snipe/README.md @@ -19,6 +19,10 @@ The package [evil-snipe](https://github.com/hlissner/evil-snipe) - enables more efficient searches with `f/F/t/T`. - adds a new, more precise search with `s/S` +Evil-snipe enables you to search more quickly and precisely in the buffer. +It does so by improving on the built in `f`/`F`/`t`/`T` searches and adding another search command, namely +`s`/`S`. + `evil-snipe` changes `s/S` behavior in order to search forward/backwards in the buffer with two chars. @@ -32,7 +36,11 @@ To use this contribution add it to your `~/.spacemacs` (setq-default dotspacemacs-configuration-layers '(evil-snipe)) ``` -### Alternate behavior for `f/F` and `t/T` +### Improved f and t search behavior + +With evil-snipe you can define your own search scope for `f` and `t` searches which means that you won't have to jump to the correct line +before searching with `f`/`t`/`F`/`T`. And after you have found a match, you can just press `f` or `t` again afterwards to continue the search. No need to use `;`/`,`. + This alternate behavior is disabled by default, to enable it set the layer variable `evil-snipe-enable-alternate-f-and-t-behaviors` to `t`: @@ -42,8 +50,11 @@ layer variable `evil-snipe-enable-alternate-f-and-t-behaviors` to `t`: '(evil-snipe :variables evil-snipe-enable-alternate-f-and-t-behaviors t )) ``` -Instead of repeating searches with `,/;` you can just press `f/t` again to -continue the search (`F/T` to go the opposite direction). +### New two-character search with s + +With the buttons `s`/`S` you can do a simple search like `f`/`t`, but instead of searching for one character, you search for two. This makes the search about 50 times more precise than regular `f`/`t` searches. While you can search forward or backwards in the buffer with `/` and `?`, `s`/`S` are much easier to reach, does not require you to press enter and is precise enough for very many common purposes. + +### More scopes Evil-snipe also adds several scope options for searches (set `evil-snipe-scope` and `evil-snipe-repeat-scope` to one of these, the default @@ -62,6 +73,21 @@ If you do not want to replace the regular `f/F/t/T` behavior, just remove this line from `evil-snipe/packages.el`: `(evil-snipe-replace-evil)` +### Symbol groups + +With symbol groups you can let a char stand for a regex, for example a group of characters. +By adding a pair of `'(CHAR REGEX)` to the list `'evil-snipe-symbol-groups` you can search for a regex very simply. + +In the first example below we set `[` to mean all characters `[({` so a search `sa[` would find both `a[`, `a{` and `a(`. +In the second example, we set the char `:` to mean a regex matching python function definitions so searching `f:fff` you can quickly cycle through all function definitions in a buffer! + +```elisp +;; Alias [ and ] to all types of brackets +(add-to-list 'evil-snipe-symbol-groups '(?\\[ \"[[{(]\")) +;; For python style functions +(add-to-list 'evil-snipe-symbol-groups '(?\\: \"def .+:\"\))" +``` + ## Key bindings TODO diff --git a/contrib/evil-snipe/packages.el b/contrib/evil-snipe/packages.el index 9075cc72c..081aff371 100644 --- a/contrib/evil-snipe/packages.el +++ b/contrib/evil-snipe/packages.el @@ -16,6 +16,6 @@ which require an initialization must be listed explicitly in the list.") evil-snipe-show-prompt nil evil-snipe-smart-case t) - (when evil-snipe-enable-alternate-f-and-t-behaviors - (evil-snipe-replace-evil) - (setq evil-snipe-repeat-scope 'whole-buffer))) + (when evil-snipe-enable-alternate-f-and-t-behaviors + (evil-snipe-override-mode t) + (setq evil-snipe-repeat-scope 'whole-buffer))