Unless a post is about vscode or eclipse, no editor flame war is intended.
To keep the comparison fair, only the defaults of the editors are used… which often show that any editor will have at some point interesting default behaviors…
Emacs is started as emacs --no-init-file ... (aka emacs -q)
Editing a file which path traverse non exiting directories triggers a warning:
Use M-x make-directory RET RET to create the directory and its parents
On save attempt, you’re explicitly asked:
Directory ‘/tmp/lol/’ does not exist; create? (y or n)
Considering vi and vim, not nvim here. Starting vi / vim with --clean
“/tmp/lol/hello” [New DIRECTORY]
So yes, vim, just like, vi displays a warning.
On save, oh boy… you’re on your own and I needed to search for the way to create directories.
“/tmp/lol/hello” E212: Can’t open file for writing Press ENTER or type command to continue
The no-config remember-able solution I can come up with is calling a shell command:
:!mkdir -p %:h
Interestingly enough, nvim shows nothing interesting in the status line opening a file behind a non-existing path.
On save, save error message shown as in vi(m) but a cleaner solution is available.
:w ++p
Nothing shown opening a file behind a non-existing path.
On save:
can’t save file, parent directory does not exist (use w! to create it)
from the :w! pop-up help message: “Force write changes to disk creating necessary subdirectories.”
Yes these editors are configurable but still, the default behavior of vi / vim / nvim is horrible, just telling you: “you’re doomed” and you realisticaly end up with Ctrl-z to your shell and running mkdir because there’s just nothing to remember.
In my opinion, there is no clear winner here. Helix has the best defaults: it’s not proposing you to create directories for you like Emacs does, it teaches you how to do it.
That said lacking a useful warning right after starting your editor telling you that the file you’re editing is not empty but lays behind non-existing directories is really useful.
Use case: copy-paste a path to a file from a failing service and not pondering why nothing was logged as the file appears empty, but knowing that the directory does not exist, so maybe the service did not start at all… (btw, a silent-ish warning is the best according to me: you don’t have to acknowledge anything, you can type right away if you want to create a file; if not, the warning will trigger you).