Tutorial: GNU nano, a text editor easier to use than vi

888u

Last update at :2024-05-28,Edit by888u

Tutorial: NANO, a text editor that is easier to use than vi

I think everyone knows the powerful functions of VI. Today I will introduce one that is not commonly used. Indeed, many merchants will install it on Linux machines. GNU nano editor.

Installation

CentOS: execute yum -y install nano

Debian: execute apt-get install -y nano

Instructions for use

nano is a character terminal text editor, a bit like the editor program under DOS. It is much simpler than vi/vim and is more suitable for Linux beginners. The default editor for some Linux distributions is nano. (nano – Nano’s ANOther editor, an enhanced free Pico clone. It’s not iPod Nano. The previous sentence is taken from the man page of the nano command, and the latter sentence was added by me)

Commonly used parameters

The nano command can open the specified file for editing. By default, it will automatically break lines, that is, when you enter too long content in one line, it will automatically split it into several lines. However, processing some files in this way may cause problems. For example, in the configuration file of the Linux system, automatic line breaking will cause the content that can only be written on one line to be broken into multiple lines, which may cause the system to malfunction. Therefore, if you want to avoid this situation, add the -w parameter. (-w (–nowrap) = Disable wrapping of long lines.)

Format: nano -w FILE

You can add an alias at the end of /etc/profile

alias nano=”nano -w”

After saving and logging in again, you can let the shell automatically add this parameter for you, that is, entering nano FILE is equivalent to nano -w FILE.

Usage examples

Example 1

[root@rhel55 ~]# nano -w test.bc

After execution is completed, a full-screen interface will appear. Note that the bottom two lines are some shortcut key tips.

GNU nano 1.3.12 File : test.bc123*321 123/321 scale=4;123/321

^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos ^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell

The following explains the prompt information in the bottom two lines. ^G means Ctrl+G, which means holding down the Ctrl key and then pressing G, then releasing it, and so on.

^G Get Help Get help

^X Exit Exit

^O WriteOut Save

^J Justify

^R Read File Read file

^W Where Is Search string

^Y Prev Page Previous page

^K Cut Text Cut an entire line

^U UnCut Text Paste

^C Cur Pos ^V Next Page Next page

^T To Spell

Get help

After entering the nano interface, there are two lines of menus below, for example, "^G Get Help". Its meaning is as follows:

^G means that the shortcut key is Ctrl+G, and "Get Help" is of course a function.

You can start using nano immediately according to these tips, or you can use Ctrl+G to see the help.

Note: In nano, white text on a black background indicates shortcut key operations. Among them, "^" represents the Ctrl key, and Ctrl+G is represented as "^G". "M" represents the Alt key, and Alt+W is represented as "M-W".

Recommended site searches: IP online query, shopex virtual host, domain name transfer, PHP space rental, registration number, how to bind domain name to server, Chinese domain name query, cm domain name, host server rental, domain name and host,

Tutorial: GNU nano, a text editor easier to use than vi

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码