Skip to content

Instantly share code, notes, and snippets.

@AdamG
Forked from rawsyntax/gist:1038120
Created June 22, 2011 19:01
Show Gist options
  • Save AdamG/1040834 to your computer and use it in GitHub Desktop.
Save AdamG/1040834 to your computer and use it in GitHub Desktop.
;; modified version of zap-to-char from emacs CVS
;;
;; http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/simple.el?revision=1.1&view=markup
;;
;; Uncomment one line to get up-to-char behavior, as referenced in
;;
;; http://www.emacswiki.org/emacs/ZapToCharUsage#toc4
(defun zap-up-to-char (arg char)
"Kill up to ARG'th occurrence of CHAR.
Goes backward if ARG is negative; error if CHAR not found."
(interactive "p\ncZap to char: ")
(kill-region (point) (progn
(search-forward (char-to-string char) nil nil arg)
(goto-char (if (> arg 0) (1- (point)) (1+ (point))))
(point))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment