0

In dired mode, 'm trying to make a function that runs dired-next-line twice and then bind to SPC so that I navigate files faster in dired mode.

I tried to add this in my dired.el file but it didn't work

(defun my-spcnxt-command()
  "Run `dired-next-line' twice."
  (interactive)
  (dired-next-line)
  (dired-next-line))
  • You are missing the argument (required) to dired-next-line. Add the argument and it works. Either add 1 to each call to dired-next-line or just use (dired-next-line 2). – Drew Apr 23 at 10:53
0

I fixed this by adding this to my dired.el file

(defun my-spcnxt-command()
  "Run `dired-next-line' twice."
  (interactive)
  (next-line 2))
  • The function works but I don't know how to bind it to SPC – user168651 Apr 23 at 9:31
  • (define-key dired-mode-map (kbd "SPC") 'my-spcnxt-command) – Drew Apr 23 at 10:50
  • You can accept your own answer, BTW. – Drew Apr 23 at 10:51
  • @Drew, I added this to my init.el file and it worked. Thank you. My function is defined in dired.el. is that okay? Or should I define in my init.el file. I can't accept my answer it says "you can accept your answer in two days" – user168651 Apr 23 at 11:01
  • It doesn't matter where the function is defined that answers your question. You can accept your answer, or any other answer, in 2 days. – Drew Apr 23 at 15:25

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.