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.

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.

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.