Hey, penguins here your penguin back again with another great article. In this article, we’re gonna be taking a look. How to fully use and utilize the nano editor beginner’s guide to nano. So for those of you also give me constantly to make an article. How to potentially get the most out of the nano Editor. Here you go now for all of my early readers. Who started off with me just you know with one of my first articles on Linux. When I did actually start using nano. If you remember my first article I actually started using VIM.
This is what a lot of you guys seem to prefer. Whatever reason is a very powerful Weditor No doubt about. That and I’ll explain why nano is very important to you to learn how to use and how to master. So for those of you actually read. That did you know that the reason I use not knowing all my articles is that. I want all my articles to essentially have no barrier for entry when it comes down to students.
User-friendly for beginner’s to use nano
So someone can easily just read it and get started without any tinkering with learning. How to use an editor. So it’s really about the topic of the article now. That being said nano is a fantastic editor very lightweight very easy to understand. I’ll be taking you through all of the short cut. All of the key bindings are used. That’ll make things a whole lot easier because a lot of you guys asking me. How to copy files, paste files on how to cut files on how to search for different words. How to move to different lines of code. so yes it is a fully functional Editor. It does have some of the best features that one would expect from an editor. SO let’s get started.
Now nano is pretty much pre-installed on any Linux. I’m not too sure if it is installed on all Linux. But it can be installed by using the default package manager of the distro. In Debian based distro use sudo apt-get install nano. I already have it installed on my MX Linux. This will pretty much be installed on any Linux. But VI or VIM is somewhat of a custom tool that one brings in mainly for productivity. I mentioned will be moving on to using VI. Perhaps I want to have these articles out there for those. Of you who like using nano as well as there is no shame in using nano. It’s a fantastic editor that gets all the work done
how to create a file with nano
So we can create a file with a nano. That can be by simply typing nano and file names as you want. I’m running nano version 3.2 and give you it a bit of information. That regards the buffer that you’ve just created. So for example, you can go and look at the bindings. That they do give you at the bottom right. That is quite important quite helpful but they don’t really explain much.
So for instance, let’s just save this to file.txt. But I can also move a bit further from then. I can save it file c. so it would be a c file. So it all depends on what you want to save it. As and also that would depend on whether or not you have coded. It will be really stupid. If I did save a text in a C file. Because That’s not what really c files are there.
So are you get the idea and the context is very very basic stuff yes so I can hit enter and it’s going to save it.
Exiting the nano editor.
Now one you want to exit to the editor uses the control + X. key on your keyboard. All right and that should exit from the buffer essentially. If you have any unsaved changes. It should prompt you to save them or to discard them depending on what you want and that usually does know denoted by the yes or no answer.
Open an already existing file with nano
Now, what if I want to open an already existing file is I can say nano and I specify the file name all the directory if it is in a particular directory so I can say. for instance, I can specify the proxychains file which is located in /etc folder. So you get the idea. perhaps I open the proxy chain file in nano.
If i wanted to open up another file from within the editor. That is again very very simple. So let’s see I’m editing one file and i want to move on to the next one.
I wanted to open up another file with in nano. So I can say for example all you need to do is hit control+r. and it’ll prompt you for the file name enter the file name. That would you open and hit enter.
It opens up the date and displays. It for us within the same buffer of course changing buffers is all dependent on whether or not you leave 1 buffer currently active. You move to the next one. sure you all too so you can essentially switch between buffers by using the ALT + > & ALT + < to switch between buffers.
Using the keyboard to copy and paste data in nano.
When we talk about copying and pasting data. This is what a lot of you guys have been asking me. So we’re going to use the nano and very simply going to open up the file. All right and now a lot of you guys are asking me how do I essentilly copy data. How do I select up a region data really that’s what you’re asking me.
So if I wanted to copy let’s say word great in my file. I wanted to go to be great. So what I would need to do is essential when selecting the region of text or data. That I want to copy all I need to do is use the ALT+a and that that’ll tell you that. The mark has been set.
Then you can use your arrows key here to select the data. That you want to copy. Once you’ve selected the data or the region of the data that you want to copy. You then use the ALT+^ sign. So now is you can actually understand. What keys amusing and that will copy the data all right.
In would great to know to do that I can simply move the copy data that you’ve copied all you need to do is use the keyboard bindings CTRL+u to copy data.
How we cut data in nano using keyborad.
Now the next thing is how we cut data in nano using the keyboard. Cutting data is very very simple. We use the essentially need to it’s very simple. We select the region of the data with the help of ALT+^ and instead of coping we cut it now for coping we use Ctrl+u. For cutting the data we use the Ctrl+K.
Perhaps when you talk about other important functionality by simply navigating through data or code. So for example, if I can just a navigate to one of my scripts here. All right so let me just move a step back here and move into my C. scripts folder. This list of files in here we have the results showed that did that we did work on so I’m just gonna open up that file right over here. I know if I’m searching or let’s actually talk about moving to the top and the bottom of your pieces of code.
Move top and bottom to file
So to the top and bottom off your file all right so to move to the top. All the beginning of the file use ALT+/ backslash. The backslash and they’ll take you to the top of your file. You want to move to the bottom you use ALT+\ forward slash. That’ll take you to the bottom. There we also ALT+/ backslash for the for the beginning and ALT+ \ forward slash for the end.
Look for a particular line number in the nano editor.
So if you want to look for a particular line number. If that’s how you called which is very very important. So let’s say I want to move to line number 11 right. So to do that I type ALT+g and that’ll ask me for the line number. You can also specify the column number. That’s what you want but for coding, you simply want to line number. So I type 11 and hit enter and it’s going to take me to the eleventh line. so that is how to search for a particular line number.
Searching for particular words.
Now when we talk about essentially. Searching for particular words and data. So if you’re looking for a string a string of data. We use the Ctrl+w keystroke and search. so let’s say I’m looking for bash word all right I can type bash and hit enter. it’s going to bring us the the results right of you we have.
Replace the word with another word in the nano editor.
If you want to replace the word with another word. You can use ALT+r. perhaps replacing data. For instance, if you were to do that essentially need to type in Alt+r and that will search. So in this case socket is selected we can say replace Socket with socks and hit enter. This will ask me to replace all sockets is I want to replace all sockets in my file I press a and hit enter. it will replace socket words with socks.
Now when you’re talking about the other keys that you can use all the other key bindings that you can traditionally use of those include various things like for example using your tab key or indentation of backspace for delete.
So those are pretty much the other keystrokes that you will find yourself maybe using but the traditional wants to work for example tapping does work. You get the idea How to fully use and utilize the nano editor beginner’s guide to nano. so that is pretty much all of the basic and advanced nano commands. That you can use when it comes down to nano and hopefully. These will increase your productivity with the tool. These pretty much should encapsulate everything. That you ever find yourself using nano. So that’s pretty much going to be for this article reference guys thank you so much for reading if you have any questions or suggestions let me know in the comments section.