Friday, October 9, 2009

GNU nano - A small, free and friendly text editor


  GNU nano is a cli (command line interface) editor for the Linux platform.  It was originally developed as a free replacement for the non-free Pico editor included as a part of the email client Pine.

  Unlike vim or emacs, nano allows even the most inexperienced user to easily create or edit text files.  Typing nano filename at the command line opens nano and either loads the file filename if it exists, or will create the file upon saving/exiting nano.

  Nano has a very short learning curve.  Immediately upon opening nano you can begin editing text, and simple,easy to remember commands control things like cut/paste and find/replace.

  Nano also includes a multitude of other options for setting things like word wrap, mouse control, etc.  These options can be specified when nano is run, or be configured to default settings by editing the .nanorc file in the user's home folder.


Here is a short list of  basic nano commands:

Saving and exiting
   If you want to save the changes you've made, press Ctrl+O. To exit nano, type Ctrl+X. If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press N in case you don't, or Y in case you do. It will then ask you for a filename. Just type it in and press Enter.

  If you accidentally confirmed that you want to save the file but you actually don't, you can always cancel by pressing Ctrl+C when you're prompted for a filename.

Cutting and pasting
   To cut a single line, you use Ctrl+K (hold down Ctrl and then press K). The line disappears. To paste it, you simply move the cursor to where you want to paste it and press Ctrl+U. The line reappears. To move multiple lines, simply cut them with several Ctrl+Ks in a row, then paste them with a single Ctrl+U. The whole paragraph appears wherever you want it.

  If you need a little more control, then you have to mark the text. Move the cursor to the beginning of the text you want to cut. Hit Alt+A. Now move your cursor to the end of the text you want to cut: the marked text gets highlighted. If you need to cancel your text marking, simply hit Alt+A again. Press Ctrl+K to cut the marked text. Use Ctrl+U to paste it.

Searching for text
   Searching for a string is easy as well.  Simply hit Ctrl+W, type in your search string, and press Enter. To search for the same string again, hit Alt+W.

Getting nano
  Nano is already installed on most modern Linux distributions, and can usually easily be added via a package manager if it isn't already installed.  If your particular flavor of Linux doesn't have a nano package available, you can build it from source by downloading the source from the nano homepage, http://www.nano-editor.org

3 comments:

  1. Thanks. I really neaded that Alt+A combo.

    ReplyDelete
  2. Glad I could help! nano also has a pretty complete help system built in as well, accessible by pressing Ctrl-G (Ctrl-X to exit help menus)

    ReplyDelete
  3. Hi, I followed this post also, it has some more advanced features.
    Your blog design is pretty sweet

    ReplyDelete

If you happened across my blog and find some of the information contained here useful, you have a question, comment, suggestion or perhaps (gasp!) a correction? Please, take a minute and leave a comment.

>