When I'm in front of the Mac, I want to use use BBEdit as my EDITOR and PAGER. When I'm connected via ssh from another computer, I need to fall back to vi and less. The following snippets handle this for me. The first one goes in a shell initialization file such as .profile or .bashrc, and the second one is a separate shell script.

if [[ ! $SSH_TTY ]]
 then
  if [ -x ~/bin/edit.sh ]
   then export EDITOR=~/bin/edit.sh
  fi
  if [ -x /usr/bin/bbedit ]
   then export PAGER="col -b | bbedit --clean --view-top"
  fi
fi # [[ ! $SSH_TTY ]]
pepper@pepperbook:~$ cat bin/edit.sh 
#!/bin/sh
# Edit in BBEdit, for programs that don't support arguments in $EDITOR.
bbedit --wait --resume "$@"

BBEdit's command-line helper (bbedit), can invoke BBEdit, but normally returns immediately after passing along the specified file(s) -- it doesn't wait for the user to finish editing the file, as a standard UNIX editor would, so Bare Bones provides the -w option to make bbedit wait to return. Unfortunately, some programs won't run a program with arguments as EDITOR, so it has to be embedded into a shell-script that adds --wait --resume internally.

The PAGER bit is similar, and inspired by a TidBITS-Talk thread.