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!
Can you share the contents of your .nanorc
file?
Do you even have a .nanorc
file?
If not, make a ~/.nanorc
file (using nano, for example) that contains this:
include /usr/share/nano/*.nanorc
Ok, gotcha, I misunderstood what you wrote first
Fantastic, now itās working! Thanks
You might also take a look at micro - it also edits in the terminal, but does LOTS more and uses more familiar shortcutsā¦
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
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.
More nano help from here:
xdg-open /usr/share/doc/nano/nano.html
(post deleted by the author)
yay -S nano-syntax-highliting
might also have solved the issue.
b.t.w.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.