what is the command to cut an entire line in emacs

3 hours ago 2
Nature

The command to cut (kill) an entire line in Emacs is:

  • Move the cursor to the beginning of the line and press C-k twice. The first C-k kills from the cursor to the end of the line, and the second C-k kills the newline character, effectively cutting the whole line

Alternatively:

  • Use the command kill-whole-line, which kills the entire line including the newline regardless of the cursor position. By default, this is bound to C-S-Backspace (Control + Shift + Backspace)

Summary:

  • C-k C-k at the start of the line cuts the entire line.
  • C-S-Backspace cuts the entire line from anywhere on the line.

If you want to configure cutting the whole line with a single key or make C-w cut the current line when no region is selected, you can customize Emacs accordingly

. Thus, the simplest built-in ways are:

  • C-k twice at the line start
  • C-S-Backspace anywhere on the line (kill-whole-line command)