The Nano Text editor

The Nano Text editor

Nano is a simple text editor that we can access right from the terminal. It's far more accessible than other popular command-line editors like vim and emacs.

Nano includes all the basic text editing functionality you would expect: search, spellcheck, syntax highlighting, etc.

To open up a file using nano, run nano FILE. For example, to open up a file "book.txt" using nano, we would run nano book.txt.

nano FILE        

We can also use the same command to edit a file that doesn't yet exist (we can then save it and create the file).

To save the file CTRL+O is used.

Suppose we have a file "groceries.txt", we can open and modify it directly from the terminal using nano.



Modify it and save it by pressing CTRL + O and then the Enter key. You can then exit the nano editor using CTRL + X.


Some editors like vim require us to enter "write mode" before we start editing a file, but with nano we can make the changes right away.

We can move the cursor using the arrow keys.

At the very bottom, we'll see a list of shortcuts that we can use inside of nano. These are super useful!

There are tons of shortcuts inside Nano but you'll only need few of them.

You can look at the help page using CTRL+G to know more about the shortcuts.



Searching and Replacing with nano

Use CTRL+W and then enter a search phrase to search FORWARD in the file from your current cursor location.

So, the cursor location is crucial and should preferably be at the start.

The shortcut to take the cursor location at the start is "ALT+ \ ".



To search and replace, use "Ctrl+\ " and then enter the word you want to replace. Then enter the replacement and decide whether to replace specific matches or all matches.




Use Y or N to replace specific instances or A to replace all matching instances.



Activating Spellcheck

We can use spellchecking inside of Nano, but we have to enable it first in the Nano config file located at /etc/nanorc.



Use CTRL+W to search for spell and then un-comment the spell checker by removing # in front of it. And then save it using CTRL+O.


Using Spellcheck

Let's intentionally have our groceries.txt file with wrong spellings.

We can now use spellchecker by first going to the execute option (CTRL+T) and then using Spellcheck option (CTRL+S).

Options for words with correct spelling will be displayed you can select your option by entering the respective number of that word in the list. Do this for all the incorrect words and then save the file using Write Out option (CTRL+O).





Thanks for reading Feel free to connect : )


要查看或添加评论,请登录

Shivm Soaini的更多文章

  • Pipelines

    Pipelines

    Pipes are used to redirect a stream from one program to another program. We can take the output of one command and…

  • The Standard Streams and Redirection

    The Standard Streams and Redirection

    The three standard streams are communication channels between a computer program and its environment. They are:…

  • Working with Files

    Working with Files

    The cat command The cat command concatenates and prints the contents of files. cat filename will read the contents of…

  • The Shortcuts

    The Shortcuts

    We can speed up our command-line experience by taking advantage of the many built-in shortcuts. These shortcuts are…

  • Deleting, Moving and Copying

    Deleting, Moving and Copying

    The rm command We use the rm (remove) command to remove files from our machine. For example, rm app.

  • Making Files and Folders

    Making Files and Folders

    The touch command To create a new file from the command line, use the touch command. Provide a filename, and that file…

  • Navigating the CLI Sea

    Navigating the CLI Sea

    The root directory The starting point for the file system is the root folder. We call it the root, but its actual…

  • Getting Help in Command Line Interface

    Getting Help in Command Line Interface

    Sometimes it's difficult to wrap our head around some of the commands we encounter. In this scenario, man pages can…

  • First Step in Command Line

    First Step in Command Line

    Some Familiar Terms A Shell is a computer interface to an operating system which expose the OS's services to the human…

  • A Brief History of Linux

    A Brief History of Linux

    The world of operating systems has many residents, but they can be segregated into two tribes: The Microsoft NT…

社区洞察

其他会员也浏览了