User Tools

Site Tools


nano

This is an old revision of the document!


The 'nano' editor is a GNU-project editor based on 'pico' a simple but easy to use editor created for the PINE email program for creating and editing emails. It has been expanded quite a bit: there is enhanced navigation, and search which include regex search.

A great addition, especially if you connect to SDF on a color terminal, is nano's use of “syntax” files, which provide syntax highlighting for several programming languages and related filetypes, such as HTML files, shell scripts, shell resource files (like .bashrc) and even the nano resource file .nanorc, where the settings for syntax file are kept.

How to Activate Syntax Hightlighting

To activate syntax highlighting, we are going to copy the default nanorc file to your user space and edit it. The steps are:

  1. copy the default file nanorc to your local as a resource file, .nanorc (yes, with the dot)
    cp /usr/pkg/share/nanorc ~/.nanorc
  2. edit the file
    nano ~/.nanorc
  3. in nano, search for the nanorc highlight line:
    1. press ctl-w, then type # include “/usr It will take you to a line that looks like:
      # include "/usr/pkg/share/nano/nanorc.nanorc"
  4. delete the '#' at the start of the line
  5. use the arrow keys to go down the rest of the file, and remove more of the comment characters '#” at the start of “include” lines, especially
    1. # Cascading Style Sheets
      # include "/usr/pkg/share/nano/css.nanorc"
    2. and
      ## HTML
      # include "/usr/pkg/share/nano/html.nanorc"
    3. and
      ## PHP
      # include "/usr/pkg/share/nano/php.nanorc"
  6. Save the file with ctl-x and press 'Y' at the save prompt and press *enter* to confirm you are saving the file as .nanorc.

The next time you open nano on an HTML or other file (it keys off the file extension, like index.html), you should see the code hightlighted, which should help your editing significantly!

nano.1651280217.txt.gz · Last modified: 2022/04/30 00:56 by peteyboy