In Nublue Blog Tuning Nano for web development | Syntax Highlighting Posted by Stefan As mentioned in my previous article 16 Really Useful Shell Commands for Web Developers I’m a fan of the nano editor for quick file edits in the Linux shell (much to the horror of the hosting team who are staunch vim users and prefer the advanced functionality of this editor). One of the reasons I started using nano is that I liked the simplicity of it, and to me the way it is structured feels intuitive. Out of the box it is a powerful editor and easy to get started with (I think most developers will find this), however it does have some excellent functionality that is not enabled as standard, which is greatly beneficial if you are looking to use nano as a web editor through the shell. Syntax Highlighting The main additional functionality is as mentioned at Linux Help (at the time of publish this link seems to be broken although google has a cached version) syntax highlighting which has the obvious benefits of making code much more readable through the shell. How to add nanos additional functionality Before starting any of this you obviously need to have nano installed on your VPS or Dedicated Server. To see how to do this have a look at /blog/16-really-useful-shell-commands-for-web-developers/#nano which shows the easy installation process for Centos/Redhat VPS and Dedicated servers Syntax Highlighting and Extra Editor Features Ok! In order to get the majority of features I’ve mentioned above you need a nano config file in place for your shell user. I’ll show how to do this for the root user, but this same process could be followed for any shell user. There are 2 ways to do this (my pre-prepared way) and the manual way: 1) The pre-prepared way I’ve created a .nanorc config file which has the Extra Editor Features I mentioned above as well as additional highlighting definitions for css, html, js and php which aren’t included as standard in the nano config (syntax highlight definitions are taken directly from http://wiki.linuxhelp.net/index.php/Nano_Syntax_Highlighting and http://code.google.com/p/nanosyntax/source/browse/trunk/syntax-nanorc/css.nanorc ). Simply download the following package I’ve put together here (which includes both my config file and the extra definitions) and do the following: Shell wget /blog/wp-content/uploads/2010/10/webdev-highlights.tar.gz 1 wget /blog/wp-content/uploads/2010/10/webdev-highlights.tar.gz Shell tar –xzf webdev-highlights.tar.gz 1 tar –xzf webdev-highlights.tar.gz Shell mv .nanorc ~/.nanorc 1 mv .nanorc ~/.nanorc Shell mv html.nanorc css.nanorc js.nanorc php.nanorc /usr/share/nano/ 1 mv html.nanorc css.nanorc js.nanorc php.nanorc /usr/share/nano/ To test try opening one of the file types mentioned or the nano config file itself (if everything is working as it should the /.nanorc file itself should have syntax highlighting). Test this by doing the following: Shell nano ~/.nanorc 1 nano ~/.nanorc And.. that should be it! 2) The manual way Manually copy the sample file and then make any edits you want to it by doing the following (obviously your nano version might be different so adjust the nano directory name accordingly): Shell cat /usr/share/doc/nano-1.3.12/nanorc.sample ~/.nanorc 1 cat /usr/share/doc/nano-1.3.12/nanorc.sample ~/.nanorc and make the edits you wish in this file. There are a few guides on doing this online (search “nano syntax highlighting” for a number of tutorials on the subject) so I won’t go into detail regarding the options but they are all fairly self explanatory in .nanorc if you go through it. NuBlue is an award-winning Web Design Company and a UK Web Hosting provider. Please get in touch and we will be happy to discuss your requirements.