While there’s an editor war on, the nano editor continues to be extremely popular. It’s the default console text editor in several different Linux distributions at this point, and it’s proven popular with some coders as well. It’s not easy to use some of the advanced options right out of the box, however, since these are mapped to keys used for other functions in graphical environments. They’ll work easily for those at virtual terminals, but they won’t work as well for those running under something like GNOME, LXDE or KDE. This makes it extremely hard to pluck out huge blocks of text that take up much of a file.
Fortunately, the software includes some other key bindings that should work under a graphical shell. For this, we’ll assume you have the nano editor up and running. That being said, there are slightly different instructions on how to delete these big chunks of text depending on whether you’ve run it from a virtual terminal or whether you’re running it from a graphical shell.
Deleting Text to the End of the File in GNU’s nano Editor
You can use the arrow keys on your keyboard to navigate through blocks of text in the nano editor. Start by positioning the cursor right in front of the text that you’d like to pluck out of the file. Now, if you’re running the program under a virtual console meaning you’ve pushed Ctrl, Alt and F2 to get to a full-screen command line environment you can actually just push Alt and T at the same time to delete all text to the end of the file. This might work in very traditional xterm, rxvt and aterm environments under a graphical environment as well.
If you’re running it under something more modern like KDE’s Konsole or the xfce4-terminal, then Alt+T is already an assigned shortcut. You should instead push and release the escape key on your keyboard, which is more than likely labeled Esc if your keyboard has labels. Once you’ve released it you can then push and release the T key. This might seem a bit unusual at first, but it should work perfectly fine. You’ll notice that a large chunk of text has been removed so that everything after the cursor is suddenly removed from the file. That being said, you haven’t saved your changes yet.
Just like you pushed and released Esc before pushing and releasing T, you can actually do the same to undo your changes. Push and release the Esc key then push U to undo the changes that you’ve made. To redo the action a second time, push Esc then release it before pushing the E key. This might take a moment to get used to, but it does become easier with a little bit of practice.
The keyboard shortcuts you might be familiar with from the world of graphical editors probably don’t work, since they too have different assignments. If you’re using a virtual terminal or an archaic graphical terminal editor, then you can use Alt+U to undo changes and Alt+E to redo them though. While Alt+E is attached to the Edit menu in most modern terminal editors, we did find that Alt+U actually worked in the xfce4-terminal instance we used to take the screenshots of this article. You might want to give that one a try, since it’s a bit easier than using the Esc key like that.
As long as you’re not making other changes, then you could continue to repeat the process of undoing and redoing the cut until you’ve reached a permanent decision. While some people do insist that there’s still a full-on editor war between the various text editors and while we’d prefer not to touch that, this trick does make GNU nano a bit more useful for those editing huge blocks of code.
For what it’s worth, GNU nano actually has many other keyboard shortcuts like this. Those using virtual terminals and such can push the F1 key to get a full list that you can scroll through with your arrow keys. Once again, though, there’s a pretty good chance that your graphical environment will intercept that key push so you can use the Ctrl+G shortcut to get the same exact help text. Push Ctrl+X to exit this list of power user’s features. Even though it won’t bring nano up to the same power levels as some other text editors, these additional shortcuts should go a long way in helping you through daily text editing tasks.
PRO TIP: If the issue is with your computer or a laptop/notebook you should try using the Reimage Plus Software which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Reimage Plus by Clicking Here