what is the command to cut an entire line in emacs
Emacs Command for Cutting a Whole Line In Emacs, the standard command to
cut (kill) an entire line, regardless of cursor position, is C-S-backspace
(Ctrl + Shift + Backspace), which invokes kill-whole-line. This kills the
full line including its newline, placing it in the kill ring for pasting with
C-y.
Default Behavior Explained
Emacs's basic kill-line (C-k) only cuts from the cursor to the end of the
line (or just the newline if at the end), so for a full line cut, you'd
typically go to line start (C-a) then C-k twice—totaling three keystrokes.
kill-whole-line streamlines this into one action, making it a go-to for
power users, though some terminals may not register C-S-backspace easily.
Note that "cut" in Emacs means "kill," which saves to the kill ring unlike
true deletion (delete commands).
Customizing for Efficiency
Many Emacs users rebind kill-line to kill-whole-line for a single C-k to
handle whole lines smartly:
(global-set-key (kbd "C-k") 'kill-whole-line)
This tweak, popularized since around 2010, checks for no active region and kills the full line—including newline—saving keystrokes since whole-line deletes are more common than partial ones.
Alternatively, redefine the cut command (kill-region) to fallback to kill- whole-line without region, as one expert has used for over a decade without
extra keybinds.
Forum and Trending Tips
Stack Overflow threads confirm newbies often seek vi's dd equivalent,
landing on these solutions, with custom binds praised for programmability.
Xah Lee’s 2010 post sparked discussions (e.g., Google+ nods), influencing
modern setups; as of 2026, it's still recommended in Emacs communities for its
efficiency over vanilla C-k.
Method| Keystrokes| Includes Newline?| Terminal-Friendly?
---|---|---|---
C-S-backspace (kill-whole-line)| 1| Yes| Sometimes no 2
C-a C-k C-k (native)| 3| Yes| Always 1
Rebind C-k to kill-whole-line| 1| Yes (smart)| Always 1
TL;DR: Use M-x kill-whole-line or C-S-backspace; bind to C-k for
speed.
Information gathered from public forums or data available on the internet and portrayed here.