├── README.md ├── doc ├── .gitignore └── easydir.txt └── plugin └── easydir.vim /README.md: -------------------------------------------------------------------------------- 1 | easydir.vim 2 | =========== 3 | 4 | A simple way to create, edit and save files and directories. 5 | 6 | What does it do? 7 | ---------------- 8 | 9 | Ever wanted to save a file and create its parent directories at the same time? 10 | 11 | Well, now you can! 12 | 13 | Here are some examples: 14 | 15 | * New directory and file... 16 | 17 | ``` 18 | :new new_directory/new_file.txt 19 | 20 | # Write some stuff to new_file.txt 21 | 22 | :w 23 | 24 | # new_directory/ is now created 25 | ``` 26 | 27 | * Create child directories inside... 28 | 29 | ``` 30 | :e existing_directory/new_directory/new_file.txt 31 | ``` 32 | 33 | * Works with horizontal and vertical splits... 34 | 35 | ``` 36 | :sp new/directory/file.txt 37 | 38 | :vsp another/new/directory/file.txt 39 | ``` 40 | 41 | Installation 42 | ------------ 43 | 44 | I highly recommend checking out Vundle or Pathogen for managing plugins. 45 | 46 | * [Vundle](https://github.com/gmarik/vundle): 47 | 48 | ``` 49 | # ~/.vimrc 50 | 51 | Plugin 'duggiefresh/vim-easydir' 52 | 53 | # Then run ':PluginInstall' 54 | ``` 55 | 56 | * [Pathogen](https://github.com/tpope/vim-pathogen) 57 | 58 | ``` 59 | $ cd ~/.vim/bundle 60 | $ git clone https://github.com/duggiefresh/vim-easydir.git 61 | ``` 62 | 63 | * [Vim Script](https://vim.sourceforge.io/scripts/script.php?script_id=4793) 64 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /doc/easydir.txt: -------------------------------------------------------------------------------- 1 | *easydir.txt* An easy way to create files and directories at the same time! 2 | 3 | Author: Doug Yun | | http://dockyard.com 4 | License: MIT License 2013 5 | 6 | INTRODUCTION *easydir* 7 | 8 | Using easydir is quite easy. Functionality remains the same for editing and 9 | saving files, but now you can prepend nonexistent directories to the desired 10 | file name to create them both. 11 | 12 | EXAMPLES 13 | 14 | :e new_directory/new_file.txt Edits a file called |new_file.txt| 15 | which is nested inside |new_directory| 16 | 17 | :sp new_directory/new_file2.txt Split a new window assign the file 18 | as |new_file2.txt| and 19 | create the directory |new_directory| 20 | 21 | :n new_dir/another_dir/file.txt You can even nest multiple directories! 22 | 23 | That's it! So *easy!* 24 | -------------------------------------------------------------------------------- /plugin/easydir.vim: -------------------------------------------------------------------------------- 1 | " Plugin: easydir.vim 2 | " Description: A simple plugin to create, edit and save files and directories. 3 | " Version: 1.2 4 | " Last Change: 2019 Dec 22 5 | " Maintainer: Doug Yun | 6 | " DockYard, LLC 2013 | http://dockyard.com 7 | " License: MIT License (MIT) | Copyright 2013 8 | 9 | if exists('loaded_easydir') 10 | finish 11 | endif 12 | let loaded_easydir = 1 13 | 14 | augroup easydir 15 | au! 16 | au BufWritePre,FileWritePre * call create_and_save_directory() 17 | augroup END 18 | 19 | function create_and_save_directory() 20 | let l:directory = expand(':p:h') 21 | if l:directory !~# '^\w\+:' && !isdirectory(l:directory) 22 | call mkdir(l:directory, 'p') 23 | endif 24 | endfunction 25 | --------------------------------------------------------------------------------