How to Use Nano Text Editor

WebsiteInternetWeb Services

Are you confused by all of the other text editors? then, this article is for you! Linux amateurs are often put off by other advanced text editors such as Vim and Emacs. While they are decent programs, they does require a bit of learning curve. Nano offers a perfect solution if you are looking for a small and friendly text editor. It offers many useful and productive features.

What is Nano Text Editor?

Nano is a text editor for Unix-like systems or any other environments using a command line interface. It emulates the Pico text editor, a part of the Pine email client, which also provides additional functionality. In contrast to Pico, Nano is licensed under the GNU General Public License (GPL).

Running Nano

Nano follows the path and opens the file if it exists. However, If it does not exist, it’ll start a new buffer with that filename in a directory. To run Nano Text editor, use the following command –

To run Nano Text editor, use the following command –

$ nano text_files/testfile

The output should be like this −

Shortcuts of Nano Text Editor

Nano text editor “commands” are commonly referred to as “shortcuts” such as read file, save file, close file etc. The most common commands are placed at the bottom of the screen, but there are many more. Note that, nano text editor does not use the Shiftkey. All shortcuts use lowercase letters and unmodified number keys.

To see a list of valid shortcuts hitCtrl+G (in your Keyboard), the output should be like this –

When you’re done looking at shortcuts, hit theCTRL+X to exit the help window.

Suppose, if you’re working on a new text file and you want to save it, then call it as “writing out”(Ctrl+O). The output window should be like this –

  • To move the cursor forward or backward, you can hit Ctrl+F andCtrl+B  respectively.
  • To move up and down one line at a time, then you can hit Ctrl+P andCtrl+N. In other words, you can use Right, Left, Up, and Down arrow keys (in your keyboard) respectively.
  • If you want to mark any text hit CTRL+^ shortcut key.

The output window should be like this-

In the above image, we have marked “their drawing rooms.”

  • To cut the marked text hitCtrl+K shortcut.
  • If you want to paste your marked text, hitCtrl+U shortcut.

Frequently Used Shortcuts

The below are a list of shortcuts which can ease your work –

CommandAction
CTRL + AMove to beginning of line
CTRL + EMove to end of line
CTRL + YMove down a page
CTRL + VMove up a page
CTRL + _Move to a specific line
CTRL + CFind out what line the cursor is currently on
CTRL + VMove up a page
CTRL + WSearch for some text
CTRL + DDelete the character currently under the cursor
CTRL + KDelete entire line
CTRL + \Replace a string of character
CTRL + OSave the content without exiting
CTRL + TWhen saving a file opens a browser that allows you to select a file name from a list of files and directories

Congratulations! Hope you perfect these basics of Nano text editor. In our next articles, we will come up with more such Linux based tricks and tips. Keep reading!

raja
Published on 22-Jan-2020 08:08:03
Advertisements