0

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.

2 Answers 2

3

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

1
  • 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, 2012 at 20:37
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .