Developer settings for the Nano text editor.

When programming on Ubuntu I regularly use nano as a text editor. For big files, it’s definitely worth sticking with the VI text editor.

Line Numbers

Ctrl + C

or

nano -c [filename]

Tab Indents

It’s a good idea to use spaces and not tabs, with 2 spaces per indent.

Edit your ~/.nanorc file (or create it) and add:

set tabsize 4
set tabstospaces

YAML File Syntax Highlighting

You can find all the highlight files here:

ls /usr/share/nano/

If you don’t see a YAML file, then it’s time to create one:

sudo nano /usr/share/nano/yaml.nanorc

Paste in the following from GitHub:

# Supports `YAML` files

syntax "YAML" "\.ya?ml$"

header "^(---|===)" "%YAML"

 

## Keys

color magenta "^\s*[\$A-Za-z0-9_-]+\:"

color brightmagenta "^\s*@[\$A-Za-z0-9_-]+\:"

 

## Values

color white ":\s.+$"

## Booleans

icolor brightcyan " (y|yes|n|no|true|false|on|off)$"

## Numbers

color brightred " [[:digit:]]+(\.[[:digit:]]+)?"

## Arrays

color red "\[" "\]" ":\s+[|>]" "^\s*- "

## Reserved

color green "(^| )!!(binary|bool|float|int|map|null|omap|seq|set|str) "

 

## Comments

color brightwhite "#.*$"

 

## Errors

color ,red ":\w.+$"

color ,red ":'.+$"

color ,red ":".+$"

color ,red "\s+$"

 

## Non closed quote

color ,red "['\"][^['\"]]*$"

 

## Closed quotes

color yellow "['\"].*['\"]"

 

## Equal sign

color brightgreen ":( |$)"