Very quick one today.
Recently I’ve started to feel the need to build out some predefined window pane layouts within emacs. This started when I realised I was spending quite a bit of time flipping between various windows while I was under utilising screen space.
Double this with some (forced) time spent in a VSCode for work and seeing what an advantage having a file tree, main code window and terminal would be - even when just playing with text. I also don’t want to have to set this up each session.
The below function can be called on any file (using M-x TJ/ide-layout
1). This will generate two additional panes, one being neotree
and the other being a terminal window taking up the lower 5th of the screen running shell
. Call this and - boom - IDE like experience.
I’m using this now as I code this blog post, able to quickly build and serve the Hugo site by without the need for external terminal.
Let me know what you think, are there any other pane setups that would help you?
(defun TJ/ide-layout ()
"Create a custom layout with neotree, terminal, and main file window. You might
want to rename this"
(interactive)
;; Delete other windows if any
(delete-other-windows)
;; Split the window horizontally into top (main file) and bottom (terminal + neotree)
(split-window-below) ;; Create a horizontal split
;; Move to the bottom pane and open a terminal
(other-window 1)
(shell) ;; Open terminal in bottom pane
;; Resize the bottom terminal window to 25% of the screen height
(shrink-window 10) ;; Shrink the bottom window, adjust as needed
;; Move back to the top pane (main file)
;; Move to the left pane and open neotree (file explorer)
(other-window 1)
(neotree-toggle) ;; Open neotree in the left pane
(neotree-refresh)
;; Move back to the main file editing pane
(other-window 1))