15

When I use less and press v it switches into the currently set editor (Emacs or vim).

MISCELLANEOUS COMMANDS
v    Edit the current file with $VISUAL or $EDITOR.

Is it possible to prevent this behavior where I don't want current file to be open in the editor?

2 Answers 2

17

You can disable v by binding it to noaction: add

# command
v noaction

to ~/.lesskey (or, if $XDG_CONFIG_HOME is set and you’re using less 582 or later, $XDG_CONFIG_HOME/lesskey), and, if you’re using less 581 or older, run lesskey.

You can also bind v to a different command. For example, to make it move down a line instead of opening an editor, use

# command
v forw-line

instead. (The default binding is visual.)

Another way to disable v in less is to set VISUAL to true:

VISUAL=true less foo

Pressing v will then run true foo, which will immediately return to less.

0
12

You may disable the v command by setting the environment variables LESSSECURE to 1.

You can set this for new shell sessions with export LESSSECURE=1 in your shell's initialisation files.

Note, though, that this also disables the !, |, :e, and the s command, as well as a few other potentially insecure features. See the "SECURITY" section in the less(1) manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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