Introduction to the nano Text Editor

Once you've logged into your linux ssh account, you'll need to use a text editor to write your code. There are a few already installed on the system (vi, emacs, etc.), but these have a bit of a learning curve associated with them. An editor that's relatively easy to learn to use is called “nano.” However, this editor is entirely operated from the keyboard, you can't use the mouse, which means you'll have to learn some simple keyboard commands. Fortunately they're pretty quick and easy to learn!

NOTE: Any command prefixed with a caret symbol (^) means to use the Ctrl key (e.g., ^G means to press the Ctrl+G keys at the same time). Any command prefixed with the letter M means to press the Alt key (e.g., M-R means to press the Alt+R keys together).



Assuming that you've logged into your linux account, issue the command to start editing with nano; below I've also provided the name of the file I wish to edit:





















After pressing the Enter key, the nano editor appears (see image below). Notice the top line, it displays the version of nano in the left corner and the name of the file being edited in the center. The lowest three lines indicate the status of the file and a list of helpful keyboard commands. Wherever you see a command using the caret symbol (^), that means to press the control key. For instance, pressing Ctrl+G will bring up the help window, and Ctrl+X will exit the program.





















At this point you can type in the text for your program. When you're ready to compile, you must first save your file to disk. Look at the next to last row, the command to write the file out is Ctrl+O:





















Entering the “WriteOut” (Ctrl+O) command will cause nano to verify your wishes:























Go ahead and press the Enter key, and nano will tell you how many lines of text it wrote to disk:





















At this point you could exit the nano program (Ctrl+X) at which point you could compile your program with g++. Or, if you'd like to read more about what's available in nano, there's online help that's always available (Ctrl+G), which brings you to this screen:





















That's probably enough to get you started! If you'd like to get more information about using nano, here are some interesting links:



Also, you should take a look at the nano keyboard commands page to become even more control over the whole process. Enjoy!