2015-12-02 14:23:39 +00:00
|
|
|
|
#+TITLE: Evil-snipe layer
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2019-05-02 21:49:30 +00:00
|
|
|
|
#+TAGS: layer|vim
|
|
|
|
|
|
2015-06-10 16:44:30 +00:00
|
|
|
|
[[file:img/Cat_With_Rifle.jpg]]
|
|
|
|
|
|
2019-05-07 20:05:06 +00:00
|
|
|
|
* Table of Contents :TOC_5_gh:noexport:
|
2017-05-22 14:16:12 +00:00
|
|
|
|
- [[#description][Description]]
|
2018-01-06 20:14:35 +00:00
|
|
|
|
- [[#features][Features:]]
|
2017-05-22 14:16:12 +00:00
|
|
|
|
- [[#install][Install]]
|
|
|
|
|
- [[#layer][Layer]]
|
|
|
|
|
- [[#improved-f-and-t-search-behavior][Improved f and t search behavior]]
|
|
|
|
|
- [[#two-character-search-with-s][Two-character search with s]]
|
|
|
|
|
- [[#more-scopes][More scopes]]
|
|
|
|
|
- [[#symbol-groups][Symbol groups]]
|
|
|
|
|
- [[#key-bindings][Key bindings]]
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
* Description
|
2019-05-26 20:58:52 +00:00
|
|
|
|
This layer adds various replacements for vim's default search functions.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2018-01-06 20:14:35 +00:00
|
|
|
|
** Features:
|
2019-05-26 20:58:52 +00:00
|
|
|
|
- Alternative implementation of vim's default search operations.
|
2018-01-06 20:14:35 +00:00
|
|
|
|
- Replacement of evil-surround with a two-character search.
|
|
|
|
|
- Support for alternative scopes for default search operations.
|
|
|
|
|
- Support for alternative motions based on configurable regexps.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
* Install
|
|
|
|
|
** Layer
|
2016-01-06 05:21:55 +00:00
|
|
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|
|
|
|
add =evil-snipe= to the existing =dotspacemacs-configuration-layers= list in this
|
|
|
|
|
file.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
** Improved f and t search behavior
|
2015-06-12 01:23:07 +00:00
|
|
|
|
With evil-snipe you can define your own search scope for ~f~ and ~t~ searches
|
2019-05-26 20:58:52 +00:00
|
|
|
|
which means that you won't have to jump to the correct line before searching
|
2015-06-12 01:23:07 +00:00
|
|
|
|
with ~f~ / ~t~ / ~F~ / ~T~. And after you have found a match, you can just press
|
2016-02-29 09:23:14 +00:00
|
|
|
|
~f~ or ~t~ again afterwards to continue the search. No need to use ~;~ / ~,~.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
|
|
|
|
This alternate behavior is disabled by default, to enable it set the
|
|
|
|
|
layer variable =evil-snipe-enable-alternate-f-and-t-behaviors= to =t=:
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
(setq-default dotspacemacs-configuration-layers
|
2015-12-10 21:07:15 +00:00
|
|
|
|
'((evil-snipe :variables evil-snipe-enable-alternate-f-and-t-behaviors t)))
|
2015-06-10 16:44:30 +00:00
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
** Two-character search with s
|
2015-06-12 01:23:07 +00:00
|
|
|
|
With the ~s~/~S~ keys you can do a simple search like ~f~/~t~, but instead of
|
2015-06-10 16:44:30 +00:00
|
|
|
|
searching for one character, you search for two. This makes the search a lot
|
2015-06-12 01:23:07 +00:00
|
|
|
|
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,
|
2019-05-26 20:58:52 +00:00
|
|
|
|
don't require you to press enter and they are precise enough for many common
|
2015-06-10 16:44:30 +00:00
|
|
|
|
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 value is =buffer=):
|
|
|
|
|
|
|
|
|
|
| Value | Description |
|
|
|
|
|
|---------------+--------------------------------------------------------------------------|
|
|
|
|
|
| buffer | search in the rest of the buffer after the cursor (=vim-sneak= behavior) |
|
|
|
|
|
| line | search in the current line after the cursor (=vim-seek= behavior) |
|
|
|
|
|
| visible | search in the rest of the visible buffer only |
|
|
|
|
|
| whole-line | same as =line=, but highlight matches on either side of cursor |
|
|
|
|
|
| whole-buffer | same as =buffer=, but highlight *all* matches in buffer |
|
2018-09-19 03:54:47 +00:00
|
|
|
|
| whole-visible | same as =visible=, but highlight *all* visible matches in buffer |
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2015-06-12 01:23:07 +00:00
|
|
|
|
If you do not want to replace the regular ~f~ / ~F~ / ~t~ / ~T~ behavior, just
|
2015-06-10 16:44:30 +00:00
|
|
|
|
remove this line from =evil-snipe/packages.el=:
|
|
|
|
|
=(evil-snipe-replace-evil)=
|
|
|
|
|
|
|
|
|
|
** Symbol groups
|
|
|
|
|
With symbol groups you can let a character stand for a regex, for example a
|
2016-03-08 08:40:28 +00:00
|
|
|
|
group of characters. By adding a pair of =(CHAR REGEX)= to the list
|
|
|
|
|
=evil-snipe-aliases= you can search for a regex very simply:
|
2016-03-12 16:51:13 +00:00
|
|
|
|
- Here we set the ~[~ character to mean =all characters [({= *in all modes* so a
|
|
|
|
|
search with ~sa[~ would find ~a[~, ~a{~ or ~a(~.
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2018-09-19 03:54:47 +00:00
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
;; Alias [ and ] to all types of brackets
|
|
|
|
|
(push '(?\[ "[[{(]") evil-snipe-aliases)
|
|
|
|
|
(push '(?\] "[]})]") evil-snipe-aliases)
|
|
|
|
|
#+END_SRC
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2019-05-26 20:58:52 +00:00
|
|
|
|
- Here we set the char ~:~ to mean "a regex matching python function
|
|
|
|
|
definitions" (but only in python-mode), so by searching with ~f:fff~ you can
|
2016-03-12 16:51:13 +00:00
|
|
|
|
quickly cycle through all function definitions in a buffer!
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2018-09-19 03:54:47 +00:00
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
;; For python style functions
|
|
|
|
|
(add-hook 'python-mode-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(make-variable-buffer-local 'evil-snipe-aliases)
|
|
|
|
|
(push '(?: "def .+:") evil-snipe-aliases)))
|
|
|
|
|
#+END_SRC
|
2015-06-10 16:44:30 +00:00
|
|
|
|
|
2018-01-06 20:14:35 +00:00
|
|
|
|
* Key bindings
|
|
|
|
|
|
2018-12-05 03:03:03 +00:00
|
|
|
|
| Key binding | Description |
|
2018-01-06 20:14:35 +00:00
|
|
|
|
|-------------+-----------------------------------------------------------------------------------------|
|
2019-05-26 20:58:52 +00:00
|
|
|
|
| ~f~ | search forward for the next entered character and set the cursor to it's position |
|
|
|
|
|
| ~F~ | search backward for the next entered character and set the cursor to it's position |
|
|
|
|
|
| ~t~ | search forward for the next entered character and set the cursor before it's position |
|
|
|
|
|
| ~T~ | search backward for the next entered character and set the cursor before it's position |
|
|
|
|
|
| ~s~ | search forward for the next entered two characters and set the cursor to it's position |
|
|
|
|
|
| ~S~ | search backward for the next entered two characters and set the cursor to it's position |
|