Called with an active region, it will replace all spaces in that region with the character corresponding to the subsequent key press. E.g., if cover-active-region is bound to C-c /, then C-c / h will replace all spaces (not newlines or anything) in the active region with the letter h.

I suppose this is a simple extension of a command that replace all characters in active region (not just whitespace).

In any case, I'm sure there is a function or idiom for this in Emacs, but I can't seem to find it.

  • You're right, @Drew. I've updated the question.
    – Dodgie
    Jan 27 '18 at 3:07
  • Please explain why the question has been voted down if you're going to vote down.
    – Dodgie
    Jan 27 '18 at 4:40
  • @Drew, I figured, otherwise you would have voted down before I made the correction. Unless you really hated my correction??
    – Dodgie
    Jan 27 '18 at 17:57
  • The question is clear now. Thx.
    – Drew
    Jan 28 '18 at 0:33
  • I was kidding :)
    – Dodgie
    Jan 28 '18 at 0:33
(defun cover-active-region (beg end char)
  "Replace space with CHAR in the region."
   (if (use-region-p)
     (user-error "No useable region")))
    " "
    (string char)
    (delete-and-extract-region beg end))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.