Closed bscuron closed 1 year ago
This is an interesting feature. What's its use-case? Personally, I've never wanted to iterate through a list of files matching a certain glob, so I'm interested to hear when you want to
One use case would be if you have to perform some directory specific actions on multiple directories that you know matches a glob pattern. For instance, say I want to delete a file inside multiple directories that contain a .git/ directory. So I would use the glob pattern ~/Documents/**/.git, delete what I need to, then use :DirbufNext and :DirbufPrev to quickly jump to the next result.
Netrw has similar commands (:Nexplore and :Pexplore)
Another useful case is if you are trying to edit a file you don't know the exact name of, but might know its file extension. You can use a glob pattern to match all files with a certain extension to browse the filesystem and see which file you are looking for.
Accidentally closed when creating my other pull request
Sorry for the slow reply! I've been in starting a new job and moving.
Did you mean to leave this PR closed?
Also in response to these changes, I think this feature would be better served by :h arglist
. So to search for multiple files you could do :argadd ~/Documents/**/.git
instead of :Dirbuf ~/Documents/**/.git
and then navigate with :next +Dirbuf\ %
and :prev +Dirbuf\ %
instead of :DirbufNext
and :DirbufPrev
. The only real drawback I see here is that you lose the behavior where running :Dirbuf ~/Documents/**/.git
automatically opens the first glob matched and highlights. But IMO I think it's more composable and intuitive to keep the behavior of :Dirbuf
simple so it doesn't accidentally do unexpected things.
I'd be happy to accept an addition to :h dirbuf-faq
mentioning this, ideally with a small 2-3 line config snippet with custom commands which do this. But in its current state, I'm not interested in merging this PR
Sorry for the slow reply! I've been in starting a new job and moving.
Did you mean to leave this PR closed?
Also in response to these changes, I think this feature would be better served by
:h arglist
. So to search for multiple files you could do:argadd ~/Documents/**/.git
instead of:Dirbuf ~/Documents/**/.git
and then navigate with:next +Dirbuf\ %
and:prev +Dirbuf\ %
instead of:DirbufNext
and:DirbufPrev
. The only real drawback I see here is that you lose the behavior where running:Dirbuf ~/Documents/**/.git
automatically opens the first glob matched and highlights. But IMO I think it's more composable and intuitive to keep the behavior of:Dirbuf
simple so it doesn't accidentally do unexpected things.I'd be happy to accept an addition to
:h dirbuf-faq
mentioning this, ideally with a small 2-3 line config snippet with custom commands which do this. But in its current state, I'm not interested in merging this PR
I can understand how it can make the use case of :Dirbuf too confusing. That is one of my problems with many plugins (adding too many features).
I will try using argadd and see how that works. Thanks for the suggestion!
Sorry for the slow reply! I've been in starting a new job and moving. Did you mean to leave this PR closed? Also in response to these changes, I think this feature would be better served by
:h arglist
. So to search for multiple files you could do:argadd ~/Documents/**/.git
instead of:Dirbuf ~/Documents/**/.git
and then navigate with:next +Dirbuf\ %
and:prev +Dirbuf\ %
instead of:DirbufNext
and:DirbufPrev
. The only real drawback I see here is that you lose the behavior where running:Dirbuf ~/Documents/**/.git
automatically opens the first glob matched and highlights. But IMO I think it's more composable and intuitive to keep the behavior of:Dirbuf
simple so it doesn't accidentally do unexpected things. I'd be happy to accept an addition to:h dirbuf-faq
mentioning this, ideally with a small 2-3 line config snippet with custom commands which do this. But in its current state, I'm not interested in merging this PRI can understand how it can make the use case of :Dirbuf too confusing. That is one of my problems with many plugins (adding too many features).
I will try using argadd and see how that works. Thanks for the suggestion!
Also it is fine to leave this pr closed!
Sorry for the slow reply! I've been in starting a new job and moving.
Did you mean to leave this PR closed?
Also in response to these changes, I think this feature would be better served by
:h arglist
. So to search for multiple files you could do:argadd ~/Documents/**/.git
instead of:Dirbuf ~/Documents/**/.git
and then navigate with:next +Dirbuf\ %
and:prev +Dirbuf\ %
instead of:DirbufNext
and:DirbufPrev
. The only real drawback I see here is that you lose the behavior where running:Dirbuf ~/Documents/**/.git
automatically opens the first glob matched and highlights. But IMO I think it's more composable and intuitive to keep the behavior of:Dirbuf
simple so it doesn't accidentally do unexpected things.I'd be happy to accept an addition to
:h dirbuf-faq
mentioning this, ideally with a small 2-3 line config snippet with custom commands which do this. But in its current state, I'm not interested in merging this PR
A workaround that I am currently using is:
" Find
command! -nargs=+ -complete=file Find set errorformat=%f | cgetexpr glob(<q-args>) | copen | cc |
nnoremap <leader>f :Find <glob pattern here>
This will populate the quickfix list with the files and directories that match the glob pattern. This way you can use :cnext and :cprev to iterate through the matches.
:Dirbuf now accepts glob patterns. For example :Dirbuf ~/Documents/*/.txt will find all of the text files in the ~/Documents directory. :DirbufNext and :DirbufPrev can be used to iterate through the glob pattern files.
When iterating through the files, at the bottom of the screen a message is printed indicating the amount of files and the index of the current file in the matched files. (1/16), (1/20), etc.