Jake Worth

Jake Worth

How to Make a New Directory and File in Vim

Published: March 11, 2022 2 min read

  • vim

How does one create a new directory and file, without leaving Vim?

Assuming you’re running a shell, I would shell out for either of these commands. Enter command mode with ESC, and then:

:! touch new-file.txt
:! mkdir new-directory

A great plugin for these actions is vim-eunuch, which gives you syntactic sugar for shell commands. Here’s the latter example, using vim-eunuch:

:Mdkir new-directory

Here’s my original answer to this question on Stack Overflow.

Get better at programming by learning with me. Subscribe to my newsletter for weekly ideas, creations, and curated resources from across the world of programming. Join me today!