Μετάβαση στο περιεχόμενο

Nano Usage

Description

GNU nano is a simple terminal-based text editor. Though not as powerful as Vim, it is easy to learn and use. Nano is ideal for making small changes to existing configuration files or for writing short plain text files.

It is often included in some popular Linux Distributions like Ubuntu, Debian and Fedora.

Usage

Opening a file

You can open a file (Example: file.txt) with nano by running nano file.txt from the command line.

Closing a file

You can close the file by pressing Ctrl+X. You will be asked if you want to save the file or discard changes. Pressing Y will prompt you to give the file a name and clicking Enter will save the file into the file name you gave as input.

Editing text

You can select text by pressing Alt+A. You can cut a line or selected text using Ctrl+K. To cut multiple lines, use a series of Ctrl+K until all desired lines have been cut. You can also copy text by pressing Alt+6.

Now that you cut/copied your desired text, you can paste it by pressing Ctrl+U.

You can find for a specified string by pressing Ctrl+W. Pressing Ctrl+W again goes to the next occurence.

You can replace a specified string by pressing Ctrl+R and typing the replacment.

  • Arrow keys: Move the cursor in the corresponding direction.
  • Ctrl+F: Move forward one character.
  • Ctrl+A: Move to the beginning of the current line.
  • Ctrl+E: Move to the end of the current line.
  • Ctrl+Y: Move one line up.
  • Ctrl+Page Up: Scroll up one page.
  • Ctrl+_: Go to a specific line or column number.

Configuration

Customization

You can further customize Nano by setting the flags below when you run it:

  • -w: Disable line wrapping.
  • -i: Enable auto-indentation.
  • -E: Enable backing up files before saving changes.
  • -A: Enable automatic hard-wrapping of long lines.
  • --tabsize=<number>: Set the width of a tab character.
  • --syntax=<syntax>: Set syntax highlighting for the specified language.