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.

What are your thoughts on this? Let me know!


Join 100+ engineers who subscribe for advice, commentary, and technical deep-dives into the world of software.