1

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

2

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")
  (save-excursion
    (forward-visible-line arg)
    (kill-whole-line)))

(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.

0

Your Answer

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

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