Using nano (text editor)
Hi Linuxers,
Are you new to Linux? Ever used nano? If no, this article is for you.
Nano is the simplest of all text editors so far I've seen. In my last post, I recommended you people to use nano, to edit GRUB defaults. This article speaks about the usage of nano. Without further delay, let's move on!
Start with Nano
This editor is simple to use, just like the GUI based ones. Whatever you type directly goes into the text field (unlike vim). You have a set of shortcuts to use, which is kinda helpful.
Essential Shortcuts (Hot Keys)
Ctrl + X (F2): Close the current buffer / Exit from nano
You can use this combination to exit from nano. It'll ask you whether to save the file if it isn't.
Ctrl+G (F1): Display help
You can use this combination, or press F1 to get to the help menu. Here, you'll find all the shortcut keys for using nano. As usual, to get out from help, press Ctrl+X.
Ctrl + O (F3): Write the current buffer to disk (save)
With this shortcut, you can save the current file if you've made changes. It's the same as Ctrl+S to save in a word processor.If you haven't saved the file, it'll humbly ask you to save it.
Ctrl + W (F6): Search forward for a string or a regular expression
This is similar to the Find menu in the word processor. Just press Ctrl+W, enter the text that you want to search, and hit enter.
If you want to find the next text, press Ctrl+W again, and hit enter. Continue this process to find the next one.
Ctrl + K (F9): Cut current line and store it in cutbuffer
This is the shortcut to cut the whole line.
Note: The cut and paste shortcuts only work inside the nano text
editor, i.e., you can't cut text from anywhere else and paste it inside
nano using the above shortcuts.
Anyways, you can paste text from some other source by middle-clicling into the text field.
Ctrl + J (F4): Justify the current paragraph
You may notice the symbol ">" at the end of some of the lines. It means that there is some text beyond the border. You can use this combination to justify the paragraph.
Before Justification |
After Justification |
After justification, the paragraph appears to be adjusted enough to be visible inside the border. This is a handy feature.
Ctrl + C (F11): Display the position of the cursor
Use this combination to display the position of the cursor in the text editor.
This combination displays the position of cursor only when you're editing the file. If you've opened something like Find menu, then Ctrl+C is used to cancel the operation.
Ctrl + _ (M-G): Go to line and column number
Use this combination to place your cursor at a particular line, like 2nd line, 5th column, etc. and press [Enter]. Your cursor will be placed at the location.
M-U and M-E: Undo and Redo the last operation
Done something wrong? Wanna undo the action? Press Meta+U. For redoing it, press Meta+E.
Wrapping up
So, I hope you people find this tutorial helpful. There are tons of other shortcut keys used in nano, but these are the essential ones.
The comment section is yours, please give your feedback.
Happy Linuxing :)
Comments
Post a Comment