Enhance nano with syntax highlighting

Why you might want syntax highlighting in nano

Nano is pretty bare-bones. That said, syntax highlighting is the one biggest upgrade to plain text nano that one can make. Syntax highlighting in nano helps the way syntax highlighting helps in any other text editor: it helps you find the salient features of a language (flow control and loops, and error messages) that might be handy for reading code.

How to upgrade nano with syntax highlighting

Anthony Scopatz has this repo of nano syntax highlighting configurations that you can use. It includes installation instructions as well!

Shell-based plain text editors give you a quick way to edit texts

Why you should learn how to use shell-based text editors

As a data scientist, you'll possibly end up working on a remote machine. This necessitates using a remote ssh session, usually in a terminal shell. At other times, in a pinch, you might need to quickly edit a file on your local filesystem and need access to a shell. Thus, knowing how to use/wrangle at least one of the built-in ones that are widely available in most systems will allow you to make quick edits on the fly.

Most important shell text editor usage steps

The most important things to learn are to:

  1. Open a file
  2. Edit and navigate through it
  3. Save and close it

As long as you can master those three actions in any text editor, you're gold. Don't worry about other extensions and add-ons until you've mastered these steps and can execute them from memory.

Which shell text editors exist?

Three of them are the most famous:

  • nano
  • vi/vim
  • emacs

The venerable nano is usually available in most systems, and has a relatively low learning curve. You can also customize it to do syntax highlighting! (see: Enhance nano with syntax highlighting)

vi/vim is the butt of many jokes on "how to exit text editors", but really it's easy:

  1. Hit escape
  2. Quickly hit :wq (the colon enters command-line mode, the w stands for write, and the q means quit)
  3. Hit enter

In normal mode, there is also: Shift + zz for save and quit, or Shift + zq for quit without save. (h/t Arkadij Kummer for surfacing this one to me.)

If you need to save the file, you'll be prompted.

Further reading

Choose and customize your development environment

At the end of the day, we choose a development environment that we are most comfortable with. The interface with our colleagues is at the level of what we share, so this should not be the highest of your concerns. Nonetheless, let me showcase where some tools can be used. Above all, avoid religious wars about text editors. Be productive, stay productive.