I'm looking for solutions/suggestions on how to delete a line not under cursor but by relative line number. For example, how to delete the line which is 5 lines after the cursor without going to it in a first place.

Emacs/Spacemacs/Evil solutions are welcomed.

1 Answer 1


This simple function and keybinding to C-c d will ask you for a number and will delete line that number forward (or backward if you will use negative number):

(defun kill-line-relative (&optional arg)
  "Kill relative line."
  (interactive "n")
    (forward-visible-line arg)

(global-set-key (kbd "C-c d") 'kill-line-relative)

You can play with interactive function parameters to use universal argument instead of explicit number request in minibuffer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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