List of content you will read in this article:
Nano is a text editor that is simple, user friendly, and perfect for beginners. If you are new to shell scripting, Nano text editor is made for you. Usually when using the Linux command line, majority of users prefer to use text editors like emacs or vim. However to get the best result out of these editors you will need a substantial amount of knowledge.
To avoid the confusions and difficulties that absolute beginners might face, Nano text editor comes to play. It is easy to use, versatile and packed with unique features.
Let’s get to the details!
This text editor is available for different operating systems like Linux and UNIX, and it is available in Ubuntu by default. Nano has all of the standard functionality such as:
- Multiple buffers
- UTF-8 encoding
- Syntax highlighting
- Spell checking and more.
This article will go through all the needed parts of Nano text editor and will serve as a complete guide for you.
For Linux Users
Create a File in Nano Text Editor
- To create a new file or open the existing file, type Nano, and write the file's name in it. For example, type nano filename and execute it for further actions.
- After executing the command, the system will open another editor window to create or edit your file.
- You will see a list at the bottom of the editor's window, so this list has basic command shortcuts of nano editor.
- All of the commands are prefixed by "^" or "M" because "^" works as the Ctrl key, and "M" works as an Alt key.
- If you want to see this list manually, then you can type Ctrl+g for it.
Editing Files in Nano Text Editor
- Nano text editor offers a modeless editor that means you can type and edit a text quickly after opening a file.
- For moving a cursor to a particular line or character number, you need to use the Ctrl+_
- This command will change the menu at the button of the window, so enter the number in the field of "Enter line number, column number:" then press the enter button.
Search or Replace a Text
- For searching a text in the file, you need to press Ctrl + W keys, type the text in the search box and press the Enter button.
- After the successful execution of the command, the cursor automatically moves that particular text. Press Alt and W keys to move to the next similar text.
- To replace a text in the file, you need to press Ctrl + \ keys and then enter the search term with the text.
- After executing the above step, the editor cursor moves to that particular text then asks for replacement.
- This cursor will move to the next matching text once the user press the Y or N keys on your keyboard. On pressing A on your keyboard, the editor will replace all of the matching texts.
Copy, Cut or Paste
- For selecting a text, move the cursor on the text then press the Alt + A keys to create a selection mark.
- Next, move the cursor to the end of that text for selecting it by using arrow keys, and the selected text will be highlighted after it.
- Now, copy that particular text by using Alt + 6 or use Ctrl + K to cut that particular text.
- Finally, move the cursor to a particular press and press Ctrl + U to paste that particular copied text.
Q. Let us know in the comments below what command was used to get the above result?
Save and Exit
- As we have described creating a file, you have to save it to make successful changes or modifications in the file. So, press Ctrl and O to save the file easily.
- If you want to exit a file, press Ctrl and X, but it will ask you to save changes if there are any unsaved change in the file.
For Windows Users
Open Nano Text Editor
- First, open the command prompt in the system and type Nano (You may want to download and install the Nano text editor before this procedure). You can also try using the nano /path/to/filename to open it.
- It will open a new window of the Nano text editor, in which you will see various options at the top of that window.
- There is a complete list of shortcut keys that you can use for obtaining the results for this text editor.
Copy, Cut, and Paste
- If you copy or cut a text, then highlight it by the cursor, or you can mark that through the Ctrl + ^.
- If you want to cut that particular text, use Ctrl + K to cut it or use Alt + ^ to copy it.
- For pasting a particular text at any place, move the cursor on that space and use Ctrl + U for pasting it. These shortcuts become handy and helpful while working on the configuration file in the Nano text editor.
This article provides all of the information that helps you use the Nano text editor. As we have stated above, many users prefer emacs or vim as a text editor, but these are advanced level editors that require higher skills and knowledge for obtaining the desired output. Therefore if you are a new user or a beginner, you can go for the Nano text editor due to its features.
This article will help you to understand creating and editing a file quickly without having any errors in the Nano Text Editor. So, go ahead and get started and come back and leave feedback if you found this article helpful.