When using find-file, list-directory and other commands, if one types a $ a minibuffer completion appears with a list of currently set environment variables.

I have no idea where this is coded, the previous link is all the documentation/information I have found regarding this feature.

Anyway, it isn't useful for my use cases, and I find it really inconvenient, especially when using completion styles that accept regexps.

Does anyone know if there is a way to disable it?

Edit: I use vertico as my completion UI, which is probably the reason why just after pressing $ I see the completion list, and I do not need to press TAB (which is the default behavior, as @Drew pointed out in a comment below).

Edit 2: I wasn't able to find where this is implemented, thus if anyone could find it it would be great. There might be hidden some hacky workaround.

  • It would be difficult to disable it I think, but it's easy to work around. Quoting from the link that you used: To access a file with ‘$’ in its name, if the ‘$’ causes expansion, type ‘$$’. This pair is converted to a single ‘$’ at the same time that variable substitution is performed for a single ‘$’. So just type two $ signs and you are done.
    – NickD
    Commented Jan 10, 2023 at 1:54
  • It's not true that just typing a $ in the minibuffer expands to env var completions. Not with emacs -Q (no init file). You have to hit TAB to cause such completion. If the latter is what you really meant then please edit to make that clear. Or if you're using some code that initiates completion automatically, and if that's important to the question, then specify that, as part of a more complete recipe to repro the behavior you want to talk about.
    – Drew
    Commented Jan 10, 2023 at 5:06
  • @NickD: Please consider posting that as an answer.
    – Drew
    Commented Jan 10, 2023 at 5:09
  • @NickD yes, that is indeed a workaround (and what I'm doing right now), but it is suboptimal, and not a solution in my opinion.
    – Ojd2000
    Commented Jan 10, 2023 at 15:23

1 Answer 1


The documented solution is to escape the $ in the filename with a second $. The link that the OP provided contains this:

To access a file with ‘$’ in its name, if the ‘$’ causes expansion, type ‘$$’. This pair is converted to a single ‘$’ at the same time that variable substitution is performed for a single ‘$’. Alternatively, quote the whole file name with ‘/:’ (see Quoted File Names). File names which begin with a literal ‘~’ should also be quoted with ‘/:’.

I don't use vertico so I'm not sure how it behaves, but if the first $ brings up a completion list, then the second $ should send the completion list away again, but that is untested by me - maybe the OP can comment.

This behavior is buried deep within the find-file interface. In particular, find-file and its relatives call find-file-read-args to read the filename. That in turn calls the minibuffer's read-file-name function which calls read-file-name-internal with a completion table that encodes the expand env variables behavior by calling substitute-in-file-name (note that this a C function in src/fileio.c, not an elisp one). I believe all this is correct as far as it goes, but it does not go very far: this is seriously complicated stuff that I wouldn't touch with a ten-foot pole. In particular, any hacks in this area are likely to break a lot of stuff. I don't think this was meant to be disabled.

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.