2

Intro:

As for beginner, i was choosing between text editors, and stopped on nano (cause work with it will make my terminal skills better. I hope.)

Problem:

As the first thing I'm facing up with nano is shortcuts. I mean they are extremely not intuitive (if i had even 5 tries for one shortcut - i will never guess the right one) and not comfortable (as example: Alt+U, Alt+E is undo, redo correspondingly, but U and E not even next keys on keyboard). And as result i was going to amend them (like so), but next thing comes to my mind was - this may be against of my aim to learn CLI.

Question:

Are the nano shortcuts "standard"? Are they used in other programs? Will learning them help me use other CLI tools or are they specific to nano?

2
  • 4
    I edited your question so it doesn't read like a request for opinion (which is not on topic here). I hope I kept the spirit of your question, please let me know if I did not.
    – terdon
    May 1 '18 at 12:26
  • Those are what the makers of the program found intuitive. I do not think. (I don't think computers or computer programs can be intuitive in a way that is remotely objective) May 1 '18 at 12:45
3

The following has been tested using nano from a terminal in MS-Windows.
It will get your nano one step closer supporting the "universal" shortcuts for copy/cut/paste etc. (at least in the Windows world).
Add these lines to the nano configfile /etc/nanorc

bind ^c copy main
bind ^v paste all
bind ^x cut main
bind ^z undo main
bind ^y redo main
bind ^f whereis main
bind F3 findnext main
bind ^h replace main
set zap
set tabsize 4
#set linenumbers

Notes:

  • set zap will change the behavior of DELETE and BACKSPACE to what a normal windows user expect i.e. the selected text will be deleted, which is not the default behavior.
  • copy and cut behave rather strange. If you haven't selected any text it will copy/cut the whole line!
  • If your nano version is < 3.00 then you have to use copytext instead of copy and uncut instead of paste. RHELish distros (RHEL, CentOS, Oracle Linux) still use the old version (as per 20 september 2020).

If you have issues selecting text in nano with shift+arrow-keys then be aware this doesn't seem to be related to nano but your terminal program.
In my case it didn't work in PuTTY, but it did work in Kitty (a fork of PuTTY, Windows-version / Linux-version).

3
  • Joined this community just to upvote you. thank you!
    – Click Ok
    Sep 26 '20 at 20:58
  • How does this work with using nano on a cluster where it is preinstalled and you only want to affect yourself and not other users. Is there a way to create the nanorc file in some directory and make nano use that one (for that user)?
    – Kvothe
    Feb 21 '21 at 17:30
  • I think so in your home folder....try to search for it or look in the manual. I cannot remember the details
    – MrCalvin
    Feb 21 '21 at 21:29
2

The only recurring concepts of command-line text editors I know of are those of vi/vim and emacs, e.g. the Vi style command mode with tab completion in cmus. I guess that's because those two are the two main competitors in this field (see the WP article about the Editor war) and both are around long enough to influence other software. If you really want to dive into command-line usage, I suggest you learn to use one of those two – both are so much more then just editors, it's really worth the time and effort. Personally, I rarely use nano at all, and then only for very simple editing tasks.

Note however that ed is the standard text editor and real programmers use butterflies.

3
  • 2
    Real programmers use butterflies is intended to be an arcane reference to nano iinm because many species of butterflies have delicate nanostructures in their wings that create their beautiful pigmentation by interacting with light.
    – karel
    May 1 '18 at 13:26
  • 1
    @karel I think it rather refers to the Butterfly effect, but that's a discussion better suited for explainxkcd.com/wiki/index.php/378. :)
    – dessert
    May 1 '18 at 13:32
  • So ... text editor. For now, If this the only case, it looks like 'pick editor -> change shortcuts as you like -> profit'. The only case of hassle with defaults, as i can devise for now, is the ability to use them naturally in alien environment.
    – user779898
    May 1 '18 at 14:00
2

Within nano, the most common keyboard shortcuts are displayed at the bottom of the terminal window for your reference. This means there is no need for you to intentionally memorize them, or to stress over knowing them.

The more you use any text editor, the more comfortable you will become and the easier it will be to make changes quickly and efficiently.

Here is an overview document to help you learn nano:

https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/

I don't recommend changing the nano default key bindings (shortcuts) but you can if you want by editing the nanorc file:

sudo nano /etc/nanorc

You can learn about the contents of the nanorc file within its corresponding man page:

man nanorc

Learning to use the terminal is about more than just using a text editor. It's about becoming comfortable using the keyboard to interact with and change a system. It's about learning to navigate the directories, and about using commands to quickly find and execute what you want to do.

Like many things, it's a process, and any time you spend using the terminal (or linux in general) will help you improve.

2
  • Agree with everything, except memorizing - i need to do it (it's just the term of effective using). But as i agree, at the same time i don't see any answer on my question - are this shortcuts applicable anywhere else or not? Only recommendation - 'don't recommend changing'.
    – user779898
    May 1 '18 at 13:18
  • @SergeiShorokhov rebind them to what you consider useful? cp /etc/nanorc ~/.nanorc and edit away ;-)
    – Rinzwind
    May 1 '18 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy