Nano editor: a configuration for code editing
12 simple configuration tips for your .nanorc file, useful for programmers!
I have already expressed my my appreciation for Gnu Nano: in my opinion it's a good editor, with a simple interface and without a steep learning curve.
So, after my previous post focused on a simple cheatsheet, today l'd like to share with my readers some .nanorc customizations, useful for programmers wich uses this editor.
1. Smooth Scrolling
Text will scroll line-by-line, instead of the usual chunk-by-chunk behavior:
2. Syntax Highlighting
This feature is extremely useful when editing the source code, or modifying configuration files:
## Nanorc files include "/usr/share/nano/nanorc.nanorc" ## C/C++ include "/usr/share/nano/c.nanorc" ## HTML include "/usr/share/nano/html.nanorc" ## TeX include "/usr/share/nano/tex.nanorc" ## Quoted emails (useful with mutt) include "/usr/share/nano/mutt.nanorc" ## Patch files include "/usr/share/nano/patch.nanorc" ## Manpages include "/usr/share/nano/man.nanorc" ## Groff include "/usr/share/nano/groff.nanorc" ## Perl include "/usr/share/nano/perl.nanorc" ## Python include "/usr/share/nano/python.nanorc" ## Ruby include "/usr/share/nano/ruby.nanorc" ## Java include "/usr/share/nano/java.nanorc" ## Assembler include "/usr/share/nano/asm.nanorc" ## Bourne shell scripts include "/usr/share/nano/sh.nanorc" ## POV-Ray include "/usr/share/nano/pov.nanorc"
Indent new lines to the previous line’s indentation. This is also useful when editing source code:
When saving a file, back up the previous version of it to the current filename suffixed with a ~:
Further, you can set the directory where Nano puts backup files:
set backupdir "/home/user/nano-backups"
5. Case Sensitive Searches
Do case sensitive searches by default:
6. Nano History
Useful for saving search/replace strings.
All search/replace strings are saved to the ~/.nano_history file, so they can be retrieved in later sessions:
7. More Editing Space
This option remove the blank line below the titlebar.
So it’s possible to use the blank line below the titlebar as extra editing space:
8. Hide help from bottom
This option hide the shortcut lists at the bottom of the screen (more editing space):
9. Disable Line Wrapping (nowrap)
Don’t wrap long lines:
10. Tab size
Set width of a tab to #cols columns (useful for python indentation):
set tabsize 10
11. Convert Tabs to Spaces
Convert typed tabs to spaces (useful for python indentation):
12. Enable Mouse
Enable the use of the mouse, useful if you move the mouse to point to another on text file, but not so useful if you need to cut or copy text.
You can of course cut and paste with Ctrl+k and Ctrl+u: