TIP. How to color Matlab syntax on Nano

Nano is quite simple and straightforward text editor you can use in Unix/Linux/OSX environment. If you are engineering/science student who codes a lot in Matlab but your situation does not allows you to develop code in Matlab GUI, using text editor like nano is good option but the fact that syntax coloring is not supported natively hinders your productivity.

So here, I brought a good solution to color your Matlab syntax on Nano editor.

  1. Open (or make) nano configuration file at your home directory
    nano ~/.nanorc
  2. Paste following lines into the file and save.
    # Matlab/Octave syntax colors
    syntax "octave" "\.m$" "\.octaverc$"
    
    # keywords
    color brightyellow "(case|catch|do|else(if)?|for|function|if|otherwise|switch|try|until|unwind_protect(_cleanup)?|vararg(in|out)|while)"
    color brightyellow "end(_try_catch|_unwind_protect|for|function|if|switch|while)?"
    color magenta "(break|continue|return)"
    
    # storage-type
    color green "(global|persistent|static)"
    
    # data-type
    color green "(cell(str)?|char|double|(u)?int(8|16|32|64)|logical|single|struct)"
    
    # embraced
    color brightred start="\(" end="\)"
    color blue start="\[|\{" end="\]|\}"
    
    # strings
    color yellow ""(\\.|[^\"])*"|'(\\.|[^\"])*'"
    
    # comments
    color brightblue "#.*|%.*"

 

Now, you can enjoy your Matlab coding in Nano!

Screen Shot 2015-11-26 at 1.49.33 AM.png

 

Reference: http://wiki.octave.org/Nano

 

Plus. Shortcuts in Nano
http://staffwww.fullcoll.edu/sedwards/Nano/NanoKeyboardCommands.html

 

Plus2. More color schemes in Nano
https://github.com/nanorc/nanorc

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s