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 and are at the shell prompt (see below), issue the command to start editing with nano. The example below shows that, if you wish, you may also provide the name of the file you want to edit:





















After pressing the Enter key, the nano editor appears (see image below). Notice the following elements:





















At this point you can type in the code for your program:





















After entering the “WriteOut” (Ctrl+o) command, nano will display a prompt on the status line to verify that you really want to write the file contents to the hard drive (see image below):























Go ahead and press the Enter key, and nano will tell you how many lines of text it wrote to disk on the status line. Notice also that the “Modified” indicator in the upper-right corner has disappeared because the file has been saved (see image below):





















At this point you could exit the nano program (Ctrl+x) to go back to the shell prompt and 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 when you're running nano, just type 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 have even more control over the whole process. Enjoy!