Nano Command Line Editor

broken image


Nano is a very lightweight command line text editor. Many Linux system administrators use Nano to do basic editing of Linux configuration files as it is easier to work with than Vim. Vim has a little bit of a learning curve that Nano don't have.In this article, I will show you how to configure the Nano text editor. So, let's get started.

You can configure Nano text editor system wide using the /etc/nanorc file.

You can also do user specific configuration of Nano text editor. In that case, you will have to create a .nanorc file in the HOME directory of the user you want to configure Nano for.

Installing Atom adds two command line commands - atom and apm. The first one runs the application itself while the second is the Atom Package Manager that's used to add and remove various components from the package listing. While these features can be set up with other editors as well, Atom takes care of them out of the box. Most Linux distributions include a text editor called nano as a standard utility. It's part of a family of text editors that includes the more robust (but significantly more complex) vi and emacs. For most uses, nano is easy to use and it doesn't require a significant learning curve.

  1. Nov 19, 2019 GNU nano is an easy to use command line text editor for Unix and Linux operating systems. It includes all the basic functionality you'd expect from a regular text editor, like syntax highlighting, multiple buffers, search and replace with regular expression support, spellchecking, UTF-8 encoding, and more.
  2. Nano is a very lightweight command line text editor. Many Linux system administrators use Nano to do basic editing of Linux configuration files as it is easier to work with than Vim. Vim has a little bit of a learning curve that Nano don't have.In this article, I will show you how to configure the Nano text editor.

I will talk about many of the configuration options Nano has and how they work. You can use the ~/.nanorc file or the system wide /etc/nanorc file. It will work for both of them.

Using ~/.nanorc File for User Specific Configuration of Nano:

The ~/.nanorc file does not exist in your login users HOME directory by default. But, you can create one very easily with the following command:

Now, you can edit the ~/.nanorc file as follows:

~/.nanorc file should be opened with Nano text editor. Now, type in your required configuration options here.

Once you're done, you have to save the file. To save the file, press + x. Then, press y.

Now, press . The changes to the ~/.nanorc configuration file should be saved.

Displaying Line Numbers in Nano:

Nano does not show line numbers by default. I will show you how to display line numbers using ~/.nanorc file and /etc/nanorc file in this section. So you will figure out how it works. From the next sections, I will use the ~/.nanorc file only for simplicity.

Using the ~/.nanorc File:

To show line numbers, type in set linenumbers in ~/.nanorc and save it.

As you can see, the line numbers are displayed.

Using /etc/nanorc File:

To display line numbers on nano system wide, open /etc/nanorc with the following command:

The /etc/nanorc file should be opened. It should look as follows. As you can see, all the nano options are already here. Most of them are disabled (commented out using # at the beginning) and some of them are enabled. Edit video in premiere pro cc.

To display line numbers, find the line as marked in the screenshot below.

Now, uncomment the set linenumbers line and save the file. Sketch hd movie online.

As you can see, the line numbers are not displayed.

Enabling Auto Indentation in Nano:

Auto indentation is not enable by default in Nano text editor. But, you can use the set autoindent option in ~/.nanorc or /etc/nanorc file to enable auto indentation in Nano text editor.

Enabling Mouse Navigation in Nano:

If you're using Nano text editor in a graphical desktop environment, then you can use your mouse to navigate. To enable this feature, use the set mouse option in ~/.nanorc or /etc/nanorc file.

Enable Smooth Scrolling in Nano:

Nano command line editor linux

You can use the set smooth option in ~/.nanorc or /etc/nanorc file to enable smooth scrolling.

Enable Word Wrapping in Nano:

Word wrapping is a very important feature of any text editor. Luckily, Nano has the ability to do word wrapping. It is not enabled by default. To enable word wrapping in Nano text editor, use the set softwrap option in ~/.nanorc or /etc/nanorc file.

Setting Tab Size in Nano:

On Nano text editor, the default tab size is 8 characters wide. That's too much for most people. I prefer a tab size of 4 characters wide. Anything more than that makes me very uncomfortable.

To define the tab size (let's say 4 characters wide) in Nano text editor, use the following option in your ~/.nanorc or /etc/nanorc file.

If you want to use a tab size of 2, then use the following option in your ~/.nanorc or /etc/nanorc file.

Automatically Converting Tabs to Spaces in Nano:

Tabs width can vary system to system, editor to editor. So, if you use tabs in your program source code, it may look very ugly if you open it with a different text editor with different tab width. If you replace tabs with specific numbers of spaces, then you won't have to face this problem again.

Luckily, Nano can automatically convert tabs to spaces. It is not enabled by default. But you can enable it with the set tabstospaces option in your ~/.nanorc or /etc/nanorc file.

Changing Title Bar Color in Nano:

You can change the title bar color in Nano text editor using the following option in your ~/.nanorc or /etc/nanorc file.

set titlecolor foregroundColorCode,backgroundColorCode

Here, the supported foregroundColorCode and the backgroundColorCode are:

white, black, blue, green, red, cyan, yellow, magenta

For example, let's say, you want to set the background title bar color to yellow and the foreground/text color to red, the option to put in the ~/.nanorc or /etc/nanorc file should be.

Changing Other Colors in Nano:

You can change colors in other parts of your Nano text editor. Other than titlecolor, there are statuscolor, keycolor, functioncolor, numbercolor options in Nano. These options are used the same way as the titlecolor option shown in the earlier section of this article.

You can see what option changes colors of which part of Nano text editor below:

Getting Help with nanorc Options:

There are many more options for configuring Nano text editor. It is out of the scope of this article to cover each and every one of them. I covered the basics. If you need something that is not available here, feel free to take a look at the manpage of nanorc.

You can read the manpage of nanorc with the following command:

The manpage of nanorc.

So, that's how you configure Nano text editor with nanorc. Thanks for reading this article.

  • Related Questions & Answers
  • Selected Reading
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.

Nano Command Line Editor For Windows 10

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 –

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 Video maker editor. 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 –

Nano Command Line Editor

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!





broken image