Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Emacs command for delete-to-char?

Tags:

emacs

In Vim, I can combine delete and search:

df[char]

to delete to (and include the char)

dt[char] 

to delete to (excluding the char).

In Emacs:

M-z : zap-to-char 

is equivalent to df[] in vim.

Is there a command for deleting to a char?

like image 205
Nick Avatar asked Nov 27 '14 03:11

Nick


2 Answers

zap-up-to-char is defined in misc.el (not loaded by default), so you can add this to your .emacs file:

(require 'misc)
(global-set-key (kbd "M-z") 'zap-up-to-char)

Apparently the behavior of M-z was changed from zap-up-to-char to zap-to-char sometime in Emacs 19 (early 90's). Some more discussion: http://www.emacswiki.org/emacs/ZapToCharUsage

misc.el is a small file (200 lines), so shouldn't hinder startup time very much, or you could copy the zap-up-to-char definition to your .emacs - see (find-function 'zap-up-to-char) after requiring misc.

like image 122
Brian Burns Avatar answered Oct 26 '22 06:10

Brian Burns


This has been addressed in emacswiki: http://www.emacswiki.org/emacs/ZapUpToChar

like image 38
lavin Avatar answered Oct 26 '22 07:10

lavin