1

C-k and M-k could delete forward to the end of line and sentence respectively.

How could only select to the end in a shortcut?

Usually select a sentence and append it to a file for further reference with the following code:

;; Captrue words
(require 'thingatpt)

(defun my-append-word ()
  (interactive)
  (let ((word (if (not (region-active-p))
                  (word-at-point)
                (buffer-substring (region-beginning) (region-end)))))
    (with-current-buffer (find-file-noselect "~/Documents/OrgMode/ORG/src/build-vocabulary.org")
      (goto-char (point-max))
      (insert word "\n")
      (save-buffer))))
2

Command mark-end-of-sentence does what you request. It's not bound to a key by default, but you can bind it to one. C-h f mark-end-of-sentence tells you:

mark-end-of-sentence is an interactive compiled Lisp function in paragraphs.el.

(mark-end-of-sentence ARG)

Put mark at end of sentence. Arg works as in forward-sentence.

If this command is repeated, it marks the next ARG sentences after the ones already marked.


You can find this command by asking apropos-command (C-h a) for commands related to "mark" and "sentence": C-h a mark sentence.

Commands that select text often have the word mark in their names, as selecting is about setting the mark at one end of the thing you're selecting (the end opposite point).


Library Thing-At-Point Commands (thing-cmds.el) has generic command select-things (aliased to the name mark-things), to select successive THINGs of any kind that has an associated forward-THING command.

If the region isn't active then you're prompted for the type of THING to use.

If the region is active, you aren't prompted, and the last-used type of THING is used again. On consecutive uses of mark-thing, the region is active, so you aren't prompted, and the region is extended to successive things of the same type.

This is true even if the region is empty, so you can just hit C-SPC to set mark and activate an empty region, then use mark-thing to select successive things of the last type used.

Command thgcmd-bind-keys (interactively or in your init file) binds C-M-SPC to select-things. (Vanilla Emacs binds C-M-SPC to mark-sexp.)

| improve this answer | |
  • Please consider accepting @xuchunyang's answer. I think it's generally better than mine, which ignored your request of selection to end-of-line. – Drew Jan 7 at 15:51
1

Use S-C-e and S-M-e, that is holding Shift while typing C-e and M-e, see (emacs) Shift Selection.

| improve this answer | |
  • @Drew M-e moves to end of current sentence. – xuchunyang Jan 6 at 18:34
  • S-C-e and S-M-e are C-k and M-k's counterparts. – xuchunyang Jan 7 at 0:33

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.