How to turn OFF (or at least override) syntax highlighting in nano via ~/.nanorc?

16,308

Solution 1

To disable syntax highlighting write following lines into ~/.nanorc:

set quiet
syntax "disabled" "."

The first line prevent error reporting. The second line defines a new color syntax.

You can also define a single syntax containing your favorite color in your ~/.nanorc:

syntax "disabled" "."
color brightgreen,black "."

I hope this helps.

Solution 2

For future references, I would add that you can run nano without colors using the command line parameter -Y

nano -Ynone myfile.txt

The "none" syntax is reserved; specifying it on the command line is the same as not having a syntax at all.

You can set an alias in your .bash_profile file:

alias nano='nano -Ynone'

Solution 3

Add the following to your ~/.nanorc file to disable syntax highlighting for all file types.

syntax "" ""
color white ""

Solution 4

This worked for me better than above since I run a white background terminal. It just makes all the text black again.

set quiet
syntax "disabled" "."
color black "."

Solution 5

There's a limitation in nano that every syntax requires at least one color rule. And, on nano 4.0 at least, the color rule's regex can't be empty. But you can make a rule that just targets whitespace, or a rule that just targets an empty line.

I'd recommend defining an extremely minimal color scheme first that applies colors in a way that you can tolerate. For example, this rule sets the background to green in places where you have trailing whitespace.

syntax "nothing" "."
color ,green "[[:space:]]+$"

You can also create a rule that targets an empty line. This rule will have no visible effect, but the right hand side is technically not empty so nano will accept it.

syntax "nothing" "."
color green "^$"
Share:
16,308
seanomlor
Author by

seanomlor

Hello, my name is Sean. I'm an Elixir and JavaScript web developer. I have over fifteen years of professional experience. My focus is on building functional web applications with Elixir, Phoenix (previously Ruby on Rails) and React.js and Redux.

Updated on June 07, 2022

Comments

  • seanomlor
    seanomlor almost 2 years

    I am struggling finding a clear answer on disabling or overriding the color settings for the nano editor.

    By default color syntax highlighting is enabled on my system. Clicking ALT+Y disables this, which is exactly what I want my default to be.

    Any ideas?