My workflow is as following: I have a common project root where folders for projects branch of. In these branches I have markdown files with notes, snippets, various information. I mark todos for example with TODO:in these markdown files.

If I want to find all my todos I :cd into the project root and perform :vimgrep /TODO:/g **/*.md . That collects all my TODOs in a quickfix window.

What can I do to collect the list of all markdown files, regardless of their contents? On this particular computer I have no rights to install additional plugins, otherwise fzf's Files: would help.

4 Answers 4


You can use the pattern \%^ to match the start of of the file. Using this, you could populate the quickfix list with the first line of all your markdown files, even empty ones.

:vimgrep "\%^" **/*.md

An alternative idea: don't use the quickfix list for a simple list of files. That's what the argument list is for! You have a lot of commands for navigating it (:help :args), and it's very versatile to populate:

The wildcards in the argument list are expanded and the file names are sorted.
Thus you can use the command "vim *.c" to edit all the C files.  From within
Vim the command ":n *.c" does the same.

White space is used to separate file names.  Put a backslash before a space or
tab to include it in a file name.  E.g., to edit the single file "foo bar": >
    :next foo\ bar

On Unix and a few other systems you can also use backticks, for example: >
    :next `find . -name \\*.c -print`
The backslashes before the star are required to prevent "*.c" to be expanded
by the shell before executing the find program.

Thus :args **/*.md should do the trick.

  • I like your alternative approach and TIL something new. It just doesn't fit as well in my workflow, as for most of the time I also search within files. Also it seems that for all args the file get's loaded, however I do not want to edit the majority of the files.
    – JohnDoe
    Sep 29, 2020 at 8:28

One trick that worked for me was

set errorformat=%f | cexpr glob('**/*.md')

The :cexpr command takes an expression and uses it to populate the quickfix list. Because the default errorformat doesn't parse plain filenames like glob returns, we set it to just include filenames.

To get something like Jake's answer and avoid setting errorformat, we could do something like this to take advantage of a default:

cexpr glob('**/*.md', v:true, v:true)->map({_, v -> v..'|1| '..v})

Packing up @jake-grossman's answer into a :Fd command (auto prefixed with the glob **/:

" Find files matching a glob and place in quick fix window, then open the qf window
" Example useage :Fd *.md
function! FindFiles(glob)
    execute ':vimgrep! "\%^" **/'.a:glob
command! -nargs=1 Fd call FindFiles(<f-args>)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.