Imagine I have an Emacs Lisp script which I execute using M-x eval-buffer
. In this script, I want to call :vsp
(vertical split) several times.
How can I do it programmatically?
C-h k
takes me to the evil-ex command. However, I cannot find there anything like vsp
or split
.
Update 1:
I found evil-window-vsplit
in evil-commands.el.
However, it doesn't work like :vsp
. If I execute the script
(evil-window-split)
(evil-window-vsplit)
(evil-window-down 1)
the window looks like shown below.
If I execute the commands C-w s
, :vsp
, and C-w j
manually, the result is this:
Update 2: It looks like (evil-window-down 1)
causes the problem.
Here is why: If I run the script
(evil-window-split)
(evil-window-vsplit)
(evil-window-vsplit)
I get the correct result (window split horizontally in two parts, the upper parts split in three parts). The bottom part is not split because there are no commands to split it in the script.
Then, I add the command for navigating to the bottom part of the horizontal split ((evil-window-down 1)
, equivalent of C-w j
):
(evil-window-split)
(evil-window-vsplit)
(evil-window-vsplit)
(evil-window-down 1)
This script produces the wrong result: Not only the upper half is split in three (like it should), but also the bottom one (it shouldn't be split).
Update 3: The above error does not occur, if I execute the script using M-x load-file
.