1

Sometimes I use dired to view or edit several files in one folder, one after the other. Dired is open in one window, and I open the files in another window by typing o in dired. When I finish with one file and kill the associated buffer, I would like focus to switch back to the dired window, instead of remaining in the window that used to hold the buffer I just killed.

  • 1
    Does opening file in another windows is critical to your workflow? Using <RET> instead of o will open file in same window and after killing the file buffer dired buffer will remain in current window. – muffinmad Jun 7 at 12:34
0

C-x 4 0 is bound to kill-buffer-and-its-window. It should do just what you're asking for in this context: kill the file buffer you're visiting and delete its window, putting you back in the previously selected window, which is the Dired window.

(Otherwise, as @muffinmad said in a comment, if you don't need to view the visited file in a separate window, but can instead view it in the window that Dired was using, then just use f or RET followed by C-x k.)

  • It must be C-x k instead of C-x 0 because C-x 0 will delete window but we want to kill buffer and stay in current window. – muffinmad Jun 8 at 19:11
  • @muffinmad: Yes, thanks; corrected the typo. – Drew Jun 8 at 19:12
  • This is what I need, thanks! I was originally thinking of something that would keep the second window open with another buffer in it, but actually there's no reason I need that. – FriendOfFred Jun 9 at 23:47

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.