it is actually possible to open a text file in less, then switch over to vim (without exiting less) and when done with editing, switch back to less.

less /open/this/file/for/viewing
# switch over to vim
:v
# now one is editing the file
# verify that one is using vim now
:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 28 2019 13:59:32)

# write and quit, switch back to less
:wq

# now one is back in less
# quit less
q

temporarily vs permanently set default editor (nano vim vi)

# temporarily set default editor
export VISUAL=vim
export EDITOR="$VISUAL"

make it permanent:

# add it to shell’s configuration file ~/.bashrc or ~/.bash_profile
# or global /etc/bash.bashrc (Debian) /etc/bashrc
# should also set $VISUAL, as some programs (correctly) use that instead of $EDITOR
echo "export VISUAL=vim" >> ~/.bashrc
echo "export EDITOR=\"\$VISUAL\"" >> ~/.bashrc

admin