knowledge/technology/applications/cli/nano.md

2 KiB

obj website repo wiki rev
application https://www.nano-editor.org https://git.savannah.gnu.org/cgit/nano.git https://en.wikipedia.org/wiki/GNU_nano 2024-01-17

nano

GNU Nano is a versatile and user-friendly text editor that comes pre-installed on many Unix-like operating systems. It is designed to be an easy-to-use, lightweight, and efficient text editor, making it a popular choice for both beginners and experienced users. Nano provides essential features for editing text files within the terminal, offering a simple and straightforward interface. A spiritual successor is micro.

Usage

To open a file using Nano, simply type:

nano filename

This will open the specified file in the Nano editor. If the file does not exist, Nano will create a new file with that name.

Key Commands

  • Ctrl + O: Write changes to the file (save).
  • Ctrl + X: Exit Nano.
  • Ctrl + G: Get help for key commands.
  • Ctrl + K: Cut the current line.
  • Ctrl + U: Paste the cut text.
  • Ctrl + W: Search for a specific string in the text.
  • Ctrl + C: Display the current cursor position.

Navigation

  • Use arrow keys to navigate.
  • Ctrl + Arrow Key: Move one word at a time.
  • Ctrl + A: Move to the beginning of the line.
  • Ctrl + E: Move to the end of the line.

Features

  1. Syntax Highlighting: Nano supports syntax highlighting for various programming and markup languages, making it easier to read and edit code.
  2. Auto-indentation: Nano can automatically indent code based on the syntax of the file, improving code readability.
  3. Search and Replace: Nano provides a simple way to search for specific strings in the text and replace them with another.
  4. Multiple Buffers: You can open multiple files in separate buffers and switch between them easily.
  5. Mouse Support: In some terminal emulators, Nano supports basic mouse interactions for scrolling and text selection.
  6. Configuration File: Users can customize Nano's behavior by creating a .nanorc configuration file in their home directory.