No syntax higlighting in nano 5.8?

Is there a way to enable colored syntax highlighting in the nano text editor? When I open for example the .bashrc file or any other file written in C, Java, etc. the whole content of the file is plain white. However when opening those files in vim, everything is highlighted correctly. I also remember using nano in other distros and not having this problem. It would be great if someone could tell me how to add it! :grinning:

Can you share the contents of your .nanorc file?

Do you even have a .nanorc file? :wink:

If not, make a ~/.nanorc file (using nano, for example) that contains this:

include /usr/share/nano/*.nanorc
7 Likes

Ok, gotcha, I misunderstood what you wrote first :sweat_smile:

Fantastic, now itā€™s working! Thanks

1 Like

You might also take a look at micro - it also edits in the terminal, but does LOTS more and uses more familiar shortcutsā€¦

1 Like

Add something like this to your .nanorc:

bind F1 help main
bind F2 curpos main
bind ^c copy main
bind ^x cut main
bind ^v paste main
bind ^z undo main
bind ^y redo main
bind ^f whereis main
bind F3 findnext main
bind ^h replace main
bind ^s writeout main
bind ^q exit main

There, ā€œfamiliarā€ shortcuts in nano.

RTFM for more nice things you can put in your .nanorc:

man nanorc
1 Like

Didnā€™t know you could get them all in there - I wonder if we should add that version of the file to our ISO? - or maybe a button to ā€˜activateā€™ it on demandā€¦

Probably not, since people who use nano tend to be used to default keybindings. Also, most guides online are made with default keybindings in mind. Changing it might cause more confusion than benefitā€¦

In any case, nano is a fairly configurable editor, you can change its behaviour significantly with a good .nanorc, but it might be better for every user to write his or her own config.

Thanks for the suggestion! I mainly use Vim and try to learn its useful features but when I want to quickly edit a file I use nano. I will also take a look at micro and see how I like it.

Alternatively,

Use vim. Nano isnā€™t much quicker in most cases. :grin:

2 Likes

More nano help from here:

  xdg-open /usr/share/doc/nano/nano.html
1 Like

(post deleted by the author)

yay -S nano-syntax-highliting might also have solved the issue. :wink:

1 Like

b.t.w.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.