Description
Nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is easy to learn and use. A lot of developers prefer this editor as it’s very simple to use and pretty useful when you only want to edit a single file quickly on your server.
One of those files that you need to change often in this kind of editor are configuration file, like yaml files. Nano offers syntax highlighting for many file types, however not for yaml files. If you want to highlight this kind of files as well, you will need to follow an extra step.
1 List available Nano Syntax Highlight Files
2 Create YAML Nano Syntax Highlighting File In order to provide syntax highlighting to your file, if the default file doesn’t exist, you need to create the syntax highlighting file for this language. This file is the yaml.nanorc file and you need to create it in the mentioned directory. Run nano to create the file:
and paste the following content:
Visit the official repository of Nano Highlight , a spiffy collection of nano syntax highlighting files for more information and languages available for nano. This file will be automatically added into nano and will highlight yaml files. Save changes and proceed with the last step.
3 Create Test Yaml File to see results As final step, you need to test wheter the highlight works or not. Proceed to create a test file with nano and write some YAML on it, for example:
Save the file, edit it again and you will now see the YAML code highlighted.