0

Good day,

I like the zap to char and zap up to char functions from evil. Since sometimes you would like to delete a prolonged sentence, I use evil-delete with selecting the char by evil-avy-goto-char-in-line. I would like to assign a command to execute both commands with one key. However I am not technical enough to know how I should parse the argument to evil-delete to make this happen. So your help in creating this function would be greatly appreciated (or alternative suggestions how to zap long lines to a particular char). A bonus would be if you could also provide the avy variant of go/zap up to char. I can't imagine how to make this happen without getting deeply involved in editing the avy code, which is obviously is not such a good idea.

Rareform
  • 199
  • 8
  • Maybe consider `evilem-motion` package with `evilem-motion-find-char`, it can override the default Evil `f/F/t/T`. – Arktik Mar 11 '23 at 10:40
  • Maybe check out `evil-snipe` package as well. – Arktik Mar 11 '23 at 10:44
  • To my knowledge evil-snipe just jumps to the next to characters indicated. Also don't understand how this would contribute to have evil-delete and evil-avy-goto-char-in-line in one command – Rareform Mar 15 '23 at 22:18

2 Answers2

1

How about something like this. Note, the F8 key is just an example, I wouldn't use it.

(defun my/zap-to-char-avy ()
  "Delete region from point to a character."
  (interactive)
  (save-excursion
    (set-mark (point))
    (evil-avy-goto-char-in-line)
    (evil-delete (mark) (point) 'block)
    (deactivate-mark)))

(define-key evil-normal-state-map (kbd "<f8>") 'my/zap-to-char-avy)
Arktik
  • 932
  • 4
  • 15
0

evil-avy-goto-char-in-line is an evil motion command, which means that you can combine it with d, y, c etc. You could bind it to f using (evil-global-set-key 'motion "f" #'avy-goto-char-in-line), then you can use df for delete, yf for yank etc. (or choose any other available key).

But you might prefer to just use the default f/F keybinding, and then get used to repeat the jumps using ;.

dalanicolai
  • 6,108
  • 7
  • 23