Skip to main content

NANO | Command Line Text Editor

In this tutorial, you will learn to open, view & edit text files using the "Nano Text Editor" by running amazing commands in the terminal.

Index

  1. Intro 
  2. Why Use Text Editors? 
  3. Let's Get Started 
  4. Open Text Editor 
  5. Create a New File 
  6. Open Existing File 
  7. Editing The File 
  8. Saving The File 
  9. Useful Cheats 
  10. Final Touch 
  11. What's Next? 

Intro

If you want features like undo/redo, syntax highlighting, line numbers, multiple files at once, replace at all locations, file locking, file backup with simple commands, then definitely you need Nano Text Editor. Nano is quite an old text editor written in C.


Text Editor is a program which allows you open, view, edit text files. Text Editors can handle many different programming languages like C, Python, Ruby, HTML, CSS, etc. There are some Softwares like Microsoft Word, Pages, Google Docs. But, we can't use them to code. Text Editors are not IDE (Integrated Development Environment). Text Editor is a very effective tool to learn code for beginners. It's the best tool to practice code than IDE.

Why Use Text Editors?

  • Easy to use 
  • Replace at all locations 
  • Cut, Copy, Paste 
  • Undo, Redo 
  • Easy Navigation 
  • Highlighting Syntax 
  • Faster 
  • Multiple Files 
  • Line Numbers 

Let's Get Started

Let's open it with a mini command. Nano is a mini Text Editor. After using it, you will be loving it.

First of all, open Terminal. You can also open the terminal by pressing (CTRL + ALT + T) (Linux Command).

To open the text editor, you can run :

DCs-MacBook-Air:~ Dhanraj$ nano

After running the "nano" command, you will see Nano Text Editor. That's looks antique & powerful.



The cursor will blink continuously in the Editor. At the top-left corner version of Nano Text Editor is shown. At top-right, it will show "Modified" if you have started typing or moved the blinking cursor. At the bottom, functioning commands with their shortcuts are shown.

To create a new file or open existing file :

DCs-MacBook-Air:~ Dhanraj$ nano fileName

To open an existing file with file path :

DCs-MacBook-Air:~ Dhanraj$ nano -w Home/Desktop/fileName

Here, -w is used for wrapping on long lines. It is very very important to use -w command because it wraps the value & checks whether it contains file or not. If a particular location contains a text file, it will open. If there is no file exists, then it will return to bash without doing any bad things like booting.

To edit the file :

You are all set up. Let's start typing. Write your own story or code in the editor.

To save the file :

If you want to save the changes you have made, use (CTRL + O). Then, you can exit the editor by using (CTRL + X). If you have pressed exit (CTRL + X) without saving(CTRL + O) it, then the editor will ask you "Save newFile?". If you want to save changes & exit, then type "y" & press enter. If you don't want to save it, then type "n" & press enter. Press (CTRL + C) to cancel & continue editing.

Useful Cheats

  • CTRL + K Cut single line
  • CTRL + U Paste the line
  • CTRL + W Search for a string
  • CTRL + O Save the file
  • CTRL + R Insert the file
  • CTRL + C Cursor position
  • CTRL + G Help
  • CTRL + T Spellchecking
  • CTRL + N One line down
  • CTRL + P One line up
Above commands are basic & very useful keystrokes while editing. In the editor, CTRL is shown as "^".

Final Touch

Good Job! You have just learned to open, view, edit & save by using amazing keystrokes in Nano.
What's Next?

In the next tutorial, we will learn to run a C program using Nano Text Editor by using amazing commands. We will dive deep into Nano Text Editor & learn advanced commands.

!!! Thank For Reading !!!
~ Coding Potter | Out Of Box Learning Series ~

Comments

Post a Comment

Popular

How to { Compile + Run } a C Program Using Nano

Hello Everyone !!! If you don't have an IDE or Software with you to run your code, then don't worry !!! We have Hulk. Oops !! Sorry that was Tony Stark's dialogue... We have Nano to Compile & Run the program. At the end of this tutorial, you will be able to compile & run a C program using Nano Text Editor on the Terminal. Intro In the previous tutorial, we learned about the basic functions of Nano Text Editor using Command Line. If you haven't seen the previous tut, then click here . I found this feature of running C program with Nano while Code Blocks Software on my Mac was continuously crashing. So, when you don't have any IDE (Integrated Development Environment), you should use Nano. Let's Get Started Let's open up the Terminal. We can use (Ctrl + Alt + T) shortcut to open the terminal. The terminal is a very powerful tool of the operating system. Creating a new file DCs-MacBook-Air:~ Dhanraj$ nano fileName.c Here,

How To Convert Integer Into ASCII Value Using C Program ?

Hi Everyone!!! At the end of this module, you will be able to get ASCII value from Integer using a C program. Intro There are many hidden tricks in C that are very useful and simple to use. Now, we are going to code a C program that converts an integer into ASCII value. Let's Go. Logic Declare a character variable Store character value to that variable from the user ("%c") Print the ASCII value ("%d") Program Output Trick Here is a trick. When we convert a character value into an integer by using ("%s" to "%d"), GNU Compiler prints the ASCII value assigned to that character. This conversion is known as Type-Casting in programming. Outro If you like it, please share it with your friends and leave your comments below. Thank You!!!