Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jessarcher/vim-heritage
Automatically create missing parent directories when saving a new file
https://github.com/jessarcher/vim-heritage
Last synced: 24 days ago
JSON representation
Automatically create missing parent directories when saving a new file
- Host: GitHub
- URL: https://github.com/jessarcher/vim-heritage
- Owner: jessarcher
- License: mit
- Created: 2021-10-09T02:58:35.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T03:55:50.000Z (6 months ago)
- Last Synced: 2024-05-22T04:38:56.317Z (6 months ago)
- Language: Vim Script
- Size: 5.86 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# heritage.vim
Heritage simply makes sure any parent directories exist when writing a new file.
This lets you do the following:
```vim
:e some/path/that/doesnt/exist.md
```And when you write the buffer (i.e. `:w`) it will create the missing directories before writing the file.
This is helpful when combined with the following mapping (taken from `:help gf`):
```vim
" Allow gf to open non-existent files relative to cwd:
map gf :edit
```This allows you to type a non-existing file path in a document like so:
```php
file_get_contents('tests/fixtures/payload.json');
```And then in normal mode with the cursor on the file path, press `gf` to open a new buffer for that path, and then be able to freely write to it without needing to manually create the path or directories.
Alternatively, you can use the following mapping to open files relative to the current file instead, similar to how the built-in `gf` works:
```vim
" Allow gf to open non-existent files relative to current file:
map gf :edit %:h/
```## Credits
* [This Stack Overflow answer](https://stackoverflow.com/a/4294176) for the code.
* [Tim MacDonald](https://twitter.com/timacdonald87) and [Jaz MacDonald](https://twitter.com/Jaz_MacDonald) for the name.## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.