Guide
Diagnosing and Fixing Missing Syntax Highlighting in GNU Nano
Step‑by‑step diagnostic guide for restoring GNU nano’s syntax highlighting when files appear in plain black/white text.
Published by Tasadduq Burney
20 Mar 2026, 20:45 UTC
3 min54.7K views0

Recognizable Condition
When opening a file with a known extension (e.g., test.c or script.py) in GNU nano, the editor displays plain white/black text. No color coding appears for keywords, strings, or comments, even though the file type matches a supported language.
Cause/Diagnostic Table
| Possible Cause | What to Look For |
|---|---|
| Terminal emulator lacks 256‑color support | echo $TERM does not end with -256color or similar |
Incorrect TERM variable | Value set to something like xterm or vt100 |
| Nano compiled without syntax highlighting | nano -V output missing +syntax or +nanossyntax |
| Missing or misplaced syntax files | Directory /usr/share/nano/ or ~/.nano/syntax/ empty or lacking *.nanorc files |
| Syntax disabled in nanorc | Personal ~/.nanorc contains set nohighlight or missing include lines |
Ordered Checks
- Verify terminal color capability
Ensure the value ends withecho $TERM-256color(e.g.,xterm-256color). If not, note the current value. - Check nano’s compile‑time features
Look fornano -V+syntaxor+nanossyntaxin the feature list. - Locate syntax files
If the command returns no output, the syntax directory may be empty or missing.ls /usr/share/nano/*.nanorc - Inspect personal nanorc
Search forcat ~/.nanorcset nohighlightor missinginclude "*/.nanorc"lines. - Test with a known file
Insert a simple C snippet (e.g.,nano /tmp/test.cint main(){return 0;}) and save. Observe whether any keyword appears in color.
Fixes Tied to Findings
- Terminal lacks 256‑color support
- Change the terminal profile to a 256‑color capable name (e.g.,
xterm-256color). - Or export the variable for the session:
export TERM=xterm-256color - After changing, restart nano and reopen the test file.
- Change the terminal profile to a 256‑color capable name (e.g.,
- Nano missing syntax support
- Reinstall nano from your distribution’s package ensuring the syntax variant is installed (e.g.,
sudo apt install nanoon Debian/Ubuntu). - If compiling from source, run:
./configure --enable-nanosyntax --enable-utf8 make sudo make install - Reinstall nano from your distribution’s package ensuring the syntax variant is installed (e.g.,
- Verify again with
nano -Vfor+syntax.
- Install the nano‑syntax package (e.g.,
sudo apt install nano-syntax). - Or copy missing files manually:
sudo cp /path/to/extra/*.nanorc /usr/share/nano/
chmod 644).- Comment out or remove
set nohighlightin~/.nanorc. - Add a global include if absent:
include "*/.nanorc"
Escalation Criteria
If after performing the above checks and fixes the file still appears without color:
- Confirm the terminal emulator truly supports 256 colors by running
and verifying the output is ≥ 256.tput colors - Test nano with a different terminal (e.g., switch from GNOME Terminal to xterm) to isolate emulator issues.
- Check for conflicting plugins or aliases that might invoke a minimal nano build (e.g.,
alias nano='nano -t'). - If the problem persists, consider filing a bug report with your distribution’s nano package, providing the output of
nano -V,echo $TERM, andtput colors.
Verification
After applying a fix, reopen a test file with a known extension (e.g., ~/test.c) containing:
#include <stdio.h> int main() { printf("Hello, world\n"); return 0; }Expect to see:
#include,int,returnin one color (keywords).<stdio.h>and the string literal in another color (strings/comments).- If colors appear, the issue is resolved.
Limitations
- The guide assumes a Unix‑like environment with access to
nanoand typical terminal emulators. - It does not cover exotic terminals that only support 8 or 16 colors; in those cases syntax highlighting will be limited or unavailable regardless of configuration.
- Changes to system‑wide nanorc (
/etc/nanorc) require root privileges and can prevent nano from launching if syntax errors are introduced; always back up before editing.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.