Home » Android » Ultimate Guide To The GNU Nano Text Editor For Termux.

Ultimate Guide To The GNU Nano Text Editor For Termux.

Poated on by

Categories Android Linux Termux

GNU nano is a simple terminal-based text editor, used in command line Interface to edit, create small text files, its similar to VIM and powerful but also user-friendly and it can be good for making small changes in text files through the command line.

Installation

1. Download and Install Termux on Android. Click here

2. Update Termux Repository.

$ apt update; apt upgrade

Or

$ pkg update; pkg upgrade

Or

$ pkg upd; pkg upg

3. Install nano package in Termux.

$ pkg install nano

Or

$ pkg i nano

However in latest Termux builds, nano text-editor is already installed.

Nano Version Check

After installation process is completed, you can check it’s version to ensure nano is installed and see the latest version number. Just type and enter…

$ nano -v
Nano
Nano – Version

Create file with nano

To create a file type nano command followed by filename.

$ nano helloword.txt

Usefull Keyboard Shortcuts For Nano

When someone says nano is fast simple and user-friendly text-editor, he/she is not joking. Nano is super easy to use and user-friendly text-editor. Here is some features and keyboard shortcuts that will amaze you.

1. Save and exit in nano

Method 1

Using CTRL + O

To save file most users use CTRL + O (Key press count: 2)

This will ask you to which file you want to write buffer. (Current file is default) just press enter. (Key press count: 1)

Now press CTRL + X to exit. (Key press count: 2)

Total key press count : 5

Method 2

Using CTRL + S

Save file CTRL + S  (Key press count: 2)

Now press CTRL + X to exit. (Key press count: 2)

Total key press count : 4

2. Search Text In Nano

CTRL + W – Search Forward

CTRL + Q  – Search Backward

ALT + W  – Continue Search Forward

ATL + Q  – Continue Search Backward

To search text in file from nano text-editor press CTRL + W or CTRL + Q.

Now type the word or text you want to search in the file and press enter.

If search is found the cursor will point to the search result.

You can continue to search next result by pressing ALT + W (forward) or ALT + Q (backword).

Nano search - easymux
Nano – Search

3. Replace Text

CTRL + \ , ALT + R – Replace text or regular expression.

1. Press CTRL + \ or ALT + R to replace text and type what you want to replace.

2. Now type text which you want to replace with. Press enter

3. If search found press…

  • Y – Replace highlighted match.
  • N – Skip highlighted match and search next one.
  • A – Replace all match at once.
  • CTRL +  C – Cancel or Stop Replacing.
Nano termux
Nano – Replace

4. Undo Redo

ALT +  U – Undo the last operation.

ALT + E – Redo the last operation.

5. Mark Text

CTRL + 6 – Mark text starting from the
cursor position.

This feature makes it easy when you want to cut or copy text from the file buffer. Use Arrow keys to mark or select.

Nano termux
nano – mark text for cut or copy

6. Cut,  Copy And Paste

CTRL + K – Cut a line or Marked text and store in cut buffer.

ALT  + 6 – Copy a line or Marked text and store in cut buffer

CTRL + U – Paste contents from cut buffer at curson position.

7. Toggle Line Numbers.

ALT + N – Enable or Desable line numbers.

If you want to display line numbers in nano press ALT + N

Press ALT + N again to hide line numbers.

Nano - line numbering
Nano – line numbering

8. Toggle Line/Word Wrapping

ALT  + S – Enable or Disable the Soft Wrap (Word Wrap) of overlong lines.

Nano - word wraping
Nano – soft wraping

9. Toggle Mouse Support

ALT + M – Enable or Desable Mouse Support.

By enabling Mouse Support you can move cursor at any line, any column easily by clicking or tapping in the file.

10. Execute Commands

CTRL + T – Insert output of a function or external command to the file.

This is very useful command you can quickly insert certain contents to the file like Path of Current Working Directory, Current Date, List of Files in Specific Directory etc.

Some Examples.

1. To Insert Path of Current Directory, press CTRL + T. And type pwd Command and press enter.

2. To insert Current Date, press CTRL + T. And type date Command and press enter.

Nano - easymux
Nano – execute command

11. Toggle Indent Mode

ALT + I – Enable or Desable Indent mode.

Indent is very useful feature while you write a code or program. You can also enable Indent mode with option -i while opening a file.

$ nano -i index.php
Nano termux
Nano – Indent

12. Handling Multiple Files

Nano is powerfull enough to handle multiple files at once. You can create/open multiple files and edit without closing the current one. To create or open multiple files type…

$ nano helloworld.sh helloworld.py

ALT + , or ALT + . – Switch between files from file buffers.

To insert new or existing file into the file buffer press…

CTRL + R then ALT + F

Now type filename or Press CTRL + T to browse and select file to insert.

Or press CTRL + C to Cancel.

Conclusion

In conclusion, nano text editor is an ideal choice for users who need a simple yet powerful text editing experience. It is user-friendly and easy to use, with an intuitive interface and plenty of features to make editing text easier. It is an open source application, meaning that it is available for free and can be tailored to fit any user’s needs or preferences. Nano is available for all major operating systems, making it a great choice for users looking for a common tool to use across different systems.


0 Comment on 'Ultimate Guide To The GNU Nano Text Editor For Termux.'

Leave a Reply

Your email address will not be published. Required fields are marked *

Search
Subscribe Us