How to open files and sub-folders in the same window in emacs?

382 Views Asked by At

I would like to open files/sub-folders in the same window which is already established in my emacs(I understand the difference between Emacs frames and windows).

Currently when I jump into Emacs I typically use C-x f in order to navigate to the folder I will be working inside of; once there I can look at the folder and its contents in Dired nicely.

However, when I then try and open a file or a sub-folder within this, by clicking or selecting it through navigating with my keyboard, it then spawns a new window beside my current one, making my screen extremely cluttered when I only wanted one window open.

How canI tell Emacs that when I am navigating in Dired I want new files and folders I move into to be opened in the window I am already working in so that I do not have to keep closing and re-opening random windows?

Apologies if this is a newbie question I am a fairly new emacs user and couldn't find this question posed elsewhere.

1

There are 1 best solutions below

3
Patience On

Try this:

(with-eval-after-load "dired"
  (define-key dired-mode-map (kbd "<mouse-2>") #'dired-mouse-find-file)
  (define-key dired-mode-map (kbd "<RET>") #'dired-find-file))

It behaved normally for me when I pressed <RET>, but the mouse click indeed opened another window. I used C-h k to see what the commands were named.