October 2012
346 pages
7h 40m
English
| Tip 44 | Save Files to Nonexistent Directories |
Vim is happy to let us edit a buffer whose path includes directories that don’t exist. It’s only when we attempt to write the buffer to a file that Vim objects. Here’s a quick tip on how to deal with this situation.
The :edit {file} command is most commonly used to open a file that already exists. But if we specify a filepath that doesn’t correspond to an existing file, then Vim will create a new empty buffer. If we press <C-g>, we’ll see that the buffer is labeled as “new file” (the <C-g> command echoes the name and status of the current file; see ctrl-G
). When we run the :write command, Vim will ...
Read now
Unlock full access