Open buffer for new files in file explorer #13355
Unanswered
jgreitemann
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Use case
I love the new file explorer, particularly the ability to open it in the current buffer's directory (<space>E by default). One remaining source of frustration arises when I need to create a new file in the same subdirectory as the current buffer. Unless I'm missing something, this requires typing
:o full/path/to/subdirectory/relative/to/workspace/root/new_file.txt
. Even with fuzzy search and tab-complete this is some effort (mostly from recalling where it actually is that I'm navigating to).Proposal
Continue to only show the files in
full/path/to/subdirectory/relative/to/workspace/root
when opening the file explorer, but include an additional entry once something has been typed. For example, while editingfull/path/to/subdirectory/relative/to/workspace/root/existing_file.txt
I could..
) would be shown,not_so_new_file.txt
(as well as any other files fuzzy matching according to the usual rules), and an entrynew_file.txt (new file)
,new_file.txt (new file)
(being the last one),full/path/to/subdirectory/relative/to/workspace/root/new_file.txt
. Like:open
, it will not actually create a file until the buffer is saved.The
(new file)
option would only be displayed when a file or directory with that exact name does not yet exist.Extension: new directories
It might also make sense to add such an option for creating directories as well, but I also see a risk of overcrowding the file explorer. New directories are created a lot less often. If included, selecting the
(new directory)
entry would simply open the file explorer in that virtual directory; from there a nested directory or a new file could be created in the same way. Just like for files and:open
, this will not yet create any directories on disk; this is delegated to:w!
.Alternative: relative paths for
:open
Instead of using the file explorer,
:open
could instead be extended to accept relative paths (which would be resolved relative to the current buffer's directory). In the above example,:o ./new_file.txt
would similarly solve that use case.The benefit of this is that it allows to tab-select an existing file and then edit the file name to create a new one without re-typing the whole name. An application that immediately springs to mind is creating a
.c
/.cpp
file for a header: given that I'm editingfull/path/to/subdirectory/relative/to/workspace/DelegateViewModelControllerFactory.h
, I could type :o ./, then tab-selectDelegateViewModelControllerFactory.h
and type <backspace>cpp<return>. Another benefit is that creating directories is trivial.The downsides of using
:open
in this way is that it is less discoverable, more crammed when navigating through the filesystem, and lacks a preview of existing files which may inform the decision where to create the new one.Beta Was this translation helpful? Give feedback.
All reactions