Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

And likewise Ctrl+Left to prevword. I read the man page of nanorc and found

bind key function menu

So the line bind ^Left prevword main would be what I want, the problem is that nano only accepts

an alpha character or the word "Space"

so Left doesn't exist.

Is there a way to accomplish this? Right now I'm on natty (nano 2.2.2) but I will upgrade nano if a later (devel?) version can do this.

share|improve this question

3 Answers

up vote 3 down vote accepted

Sadly, I don't think this is possible. I've found a thread where a nano developer said:

Hi, I've searched high and low trying to find out if it's possible to navigate through the text with CTRL left/right-key to jump word by word...

Unfortunately, no. Meta-Space and Ctrl-Space are the only keys to do that. This is because in text mode, there's no way for nano to tell the difference between Ctrl-Left and Left and between Ctrl-Right and Right.

On another, he added:

because I figure that nano should work the same way under both X terminals and the console, and I have yet to find a console that can distinguish between [arrow key] and Ctrl-[arrow key]. I do wish that wasn't the case...

share|improve this answer
As sad as it is I'm gonna have to accept your answer. Cool that you not only found out but also found this question! – turbo Feb 24 '12 at 11:34

There is a solution to this problem. Redefine Ctrl-Left and Ctrl-Right in your Terminal program to seldom-used keys, such as F13 and F14.

Then in ~/.nanorc:

bind F13 prevword main
bind F14 nextword main

Now, a shortcoming, for me at least, is that it will only work when you're using the Terminal program you used for the key redefinition. For example, in my situation, this doesn't work when I'm at the physical console of my OS (in my case, FreeBSD). But I use QVT/Term from my desktop in the other room almost 100% of the time. Works like a charm.

share|improve this answer
Interesting. What terminal did you use? I looked for a setting like this in gnome-terminal and couldn't find anything. Normally I use stjerm and haven't seen anything like that either. – turbo Aug 26 '12 at 10:47
As I stated above, I use a product called QVT/Term. It's a simple telnet program, albeit a very cool one, that I downloaded in Aug. of 1998 directly from the company (QPC Software). Can't seem to find any new versions. I have the emulation set at 'VT220-7bit'. However, these keys should be redefinable in your *NIX shell. I haven't researched that yet, only because the terminal option was right in front of me. – Kingpin Aug 27 '12 at 19:32

I don't have a direct answer, but this problem is what prompted me to study vim; as many linux pros will tell you, nothing beats vim. After a few months of practice, I believe they are right. I used to hate vim because I didn't know how to use it, and preferred nano, simply because it was more like notepad. Now, nano seems pretty useless to me. So, my answer is:

sudo apt-get install vim
vimtutor

Hope that isn't an unwelcome suggestion; I can't but think you'll appreciate it in the long run (the feature you are looking to implement is built into vim by default).

share|improve this answer
not really helpful... Of course there are other programs capable of achieving my goal, but nano is the default on Ubuntu (and considering the "few months practice" of vim... not an option). – turbo Jun 20 '11 at 15:59
Well, you can change the default editor with sudo update-alternatives –config editor; vimtutor only takes 25-30 minutes to complete. After that, it's a matter of what you want to do with it. – Yuttadhammo Jun 25 '11 at 11:39
Yeah I know, it's just that since nano is default for so long, there are several tweaks in .nanorc one would have to find alternatives to in vim. That just takes time, therefore not for me. – turbo Jun 25 '11 at 14:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.