Use case or problem
I like to create new files from within the Quick Switcher, so I can search for existing files on a topic then decide to create a new one if it isn’t there, as part of a single flow. If the search field contains the complete path of the new file I want to create, I can press shift-enter to create it.
When I decide to create a new file, I may want to create it in a nested sub-folder. As far as I can tell, the only way to do this from within the Quick Switcher is to manually type every character of the path. I would like the ability to auto-complete this path, so I can save typing and am less likely to misspell a path part.
This could also be an intuitive alternate way to select a search result: auto-complete to its final name, then press enter.
Notice that [[
completion in the editor already has completion behaviors similar to these. This feature request makes them available to Quick Switcher.
Proposed solution
With the Quick Switcher open, if the entire string in the search field matches the prefix of a path to a directory or file in the vault, when I press the tab key, Obsidian completes the path using canonical path completion rules similar to a Linux shell. If the prefix is unique to a path part up to a path delimiter (directory) or up to the end of the path (file; but not beyond the next path delimiter), complete the path part, including a trailing path delimiter (forward slash) in the case of a directory. If the prefix is shared by multiple path parts, complete only up to the first character that differs between the path parts.
For example, given a vault with these existing paths:
Journal/2022-02-28
Journal/2022-03-01
Journal/2022-03-02
Zettelkasten/Topics/Nature
Zettelkasten/Topics/Nuture
- If the search field contains
Jo
and I press tab, it updates to:Journal/
- If the search field contains
Journal/
and I press tab, if updates to:Journal/2022-
- If the search field contains
Ze
and I press tab, it updates to:Zettelkasten/
- If the search field contains
Zettelkasten
and I press tab, it updates to:Zettelkasten/
- If the search field contains
Zettelkasten/
and I press tab, it updates to:Zettelkasten/Topics/
- If the search field contains
Zettelkasten/Topics/
and I press tab, it updates to:Zettelkasten/Topics/N
- If the search field contains
Zettelkasten/Topics/N
and I press tab, nothing happens. - If the search field contains
Zettelkasten/Topics/Q
and I press tab, nothing happens.
Related polish: When Quick Switcher is displaying results, I can use up/down cursor keys to select a result. If I press the tab key with a result selected, Obsidian updates the search field text to be the path of the result, and the cursor returned to the end of the search field. This would allow me to choose an existing path that I have matched, delete the path suffix, enter a new suffix, and create a new file with a path prefix similar to the result.
For example, given the above vault paths, a search field containing Nat
would have Zettelkasten/Topics/Nature
as its sole result. If I press down to select it, then tab, the search field updates to Zettelkasten/Topics/Nature
with the cursor at the end of the field.
Other considerations
I’m not sure I’ve described the [[
completion behavior precisely. It’s not clear whether Quick Switcher completion should use the exact behavior of [[
completion or if something slightly different is warranted for polish.
I don’t know if this feature would benefit from special handling of spaces in paths, such as with additional support for “quoted terms” in Quick Switcher. Without special support, completion would assemble valid paths and match existing files under those paths, but may also match other files via terms formed by spaces in the completed path. My guess is quoted terms can be a separate feature request, and would extend both matching logic and the way the path completer works (by adding quotes when introducing spaces via completion). It is not needed to fulfill this use case.
I can’t think of a use case for this where the entire search string isn’t a full path prefix, but just to explore this idea a bit: if my search field contains alpha beta Ome
, there exists a top level Omega
directory, and I press tab, perhaps I would expect this to complete to alpha beta Omega/
. With support for quoted terms, if there exists a top level Omega Pi
directory (and no other completions exist), it would complete to alpha beta "Omega Pi/"
, with the cursor to the left of the second "
. This would not be useful for creating a new topic so I’m not sure this needs to be supported.
If anything, the non-path case should complete terms, not path parts: if Omega
is a known word in file paths and there are no other completions, alpha beta Ome
could complete to alpha beta Omega
with a trailing space and without a trailing path delimiter. Only use path completion logic if the entire search field matches a path prefix. Term completion could be a separate feature request.
Current workaround
As far as I can tell, to create a topic from the Quick Switcher in a subdirectory, I must type the entire directory path. It’s possible that a search result with a similar path prefix is already being displayed, but I have to manually transcribe the path from the result.