Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can't make less use my favorite editor. To my horror, it starts ed which I've never used and really am not going to.

> echo $EDITOR 
emacsclient
> less somefile

Pressing v starts usr/bin/editor +7 somefile. I've never seen less ignoring $EDITOR, so it may be an Ubuntu issue.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Try adding "export EDITOR". The behaviour of unexported shell variables is really confusing, but I can reproduce this problem myself.

If that still doesn't work, "sudo update-alternatives –config editor" will let you configure /usr/bin/editor

share|improve this answer
    
My bad... I always use things like export EDITOR=emacsclient; export VISUAL="$EDITOR"; export LESSEDIT="$EDITOR '%f'" and this time I copied it from somebody else... –  maaartinus Feb 15 '12 at 20:37
add comment

less pays attention to three environment variables to determine what editor to invoke for the v command: $VISUAL, $EDITOR, and $LESSEDIT. man less and search for LESSEDIT for details.

Normally it probably makes sense to set $EDITOR to your favorite editor and leave $VISUAL and $LESSEDIT undefined. (The distinction between $EDITOR and $VISUAL is probably not useful these days; it used to be a way to distinguish between a full-screen editor like vi and a line-oriented editor like ed.)

And as pjc50 says, be sure the $EDITOR variable is exported.

share|improve this answer
add comment

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.