سؤال

Is there an Emacs function to delete (forward or backwards) until the first whitespace? For example, I have the following line, and the cursor is marked by the caret:

someword ?(&)!* morewords
               ^

I want to delete the backwards the sequence of non-alphanumeric characters, but not the word someword. Using backward-delete-word will wipe out the word as well. The same is with the cursor before the weird characters and kill-word.

هل كانت مفيدة؟

المحلول

I don't know of any function, but it's easy enough to make one:

(defun my-delete-backward-to-ws ()
  (interactive)
  (delete-region (point) (save-excursion (skip-syntax-backward "^ ") (point))))

نصائح أخرى

emacs has the function zap-to-char which will delete everything up to a specific character. So, this won't work for all whitespace but if your specific problem is everything up to a space you can use this function. Give the function a negative argument to zap backwards.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top