macOS空格键文件预览功能失效求助:无扩展名文件无法预览
Got it, let's work through this Quick Look issue you're facing. I've dealt with similar headaches after fresh macOS setups, so here's a breakdown of what's going on and how to fix it:
Why MacVim made a difference
MacVim installs a custom Quick Look generator (MacVim.qlgenerator) that explicitly tells macOS to treat extensionless files as text for preview purposes. When you removed MacVim, that generator was deleted too, leaving the system unsure how to handle these files—even though they're plain text.
Step-by-step fixes
1. Diagnose the problem first
First, let's confirm how macOS is classifying your file. Open Terminal and run:
mdls -name kMDItemContentType your-file-name
- If the output is
public.plain-text, macOS recognizes it as text but Quick Look might be misbehaving. - If it's something generic like
public.data, that means macOS doesn't know it's text—this is the likely culprit.
You can also test Quick Look directly from Terminal to see error messages:
qlmanage -p your-file-name
This will open the Quick Look window and print debug info in Terminal if it fails.
2. Force macOS to treat extensionless files as text
The easiest way to fix this is to set a system-wide association for extensionless files to the plain text type. Here are two methods:
Option A: Use duti (recommended)
First, install Homebrew if you don't have it, then install duti (a tool for managing default apps and Quick Look associations):
brew install duti
Then run this command to map extensionless files to Apple's default text Quick Look generator:
duti -s public.plain-text com.apple.QuickLookTextGenerator all
Option B: Manual Finder settings
For a GUI approach:
- Right-click your extensionless file → Get Info
- Under Open with, select TextEdit (or any text editor you prefer)
- Click Change All... and confirm when prompted
This tells macOS to open all extensionless files with your chosen editor, and Quick Look will follow this association to preview them as text.
3. Reset Quick Look cache
Sometimes cached data causes preview issues. Reset it with these Terminal commands:
qlmanage -r qlmanage -r cache killall Finder
Then log out and back in to make sure changes take effect.
4. Use a third-party Quick Look plugin (if needed)
If the above steps don't work, install a lightweight text-focused Quick Look plugin that handles extensionless files well. Two popular options:
brew install qlcolorcode qlstephen
After installation, reset the Quick Look cache again (qlmanage -r) and test your files. These plugins are designed to preview all kinds of text files, regardless of extensions.
内容的提问来源于stack exchange,提问作者A-Trujillo




