Skip to Content
Practical Vim, 2nd Edition
book

Practical Vim, 2nd Edition

by Drew Neil
October 2015
Intermediate to advanced
356 pages
7h 54m
English
Pragmatic Bookshelf
Content preview from Practical Vim, 2nd Edition
Tip 45Save 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 attempt to write the contents of that buffer to a new file using the filepath that was specified when ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Modern Vim

Modern Vim

Drew Neil
Learning the vi and Vim Editors, 7th Edition

Learning the vi and Vim Editors, 7th Edition

Arnold Robbins, Elbert Hannah, Linda Lamb

Publisher Resources

ISBN: 9781680501629Errata Page