Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to launch vim instead of the default vi editor when I hit v in less.

Are there any settings I can modify to allow me to do this?

share|improve this question
up vote 26 down vote accepted

From man less,

v      Invokes  an  editor  to edit the current file being viewed.  The
       editor is taken from the environment variable VISUAL if defined,
       or  EDITOR if VISUAL is not defined, or defaults to "vi" if nei‐
       ther VISUAL nor EDITOR is defined.  See also the  discussion  of
       LESSEDIT under the section on PROMPTS below.

Simply set standard EDITOR environment variable according to your wishes, e.g. export EDITOR=vim in ~/.bashrc or something like that.

share|improve this answer
This may not matter to much anymore, but the original intent of the two environment variables was that VISUAL was curses-based (vi or emacs) and EDITOR was tty based (ed), which is why less looks for VISUAL first. There may still be programs out there that see this difference. I would suggest setting VISUAL instead of EDITOR. – Arcege Feb 10 '11 at 12:08
@Arcege: small correction: VISUAL is supposed to point to a full-screen (and not line-based) editor. Even though vi was, deep down, a line-based editor ("vi" (originally) stood for "visual interface" (to "ex", an enhanced "ed"). – Jürgen A. Erhard Feb 10 '11 at 12:27
@Arcege: Definitely, I remember having some issues when I set EDITOR to vim. VISUAL is more suitable. I don't remember what the issues were, but if you use the cli frequently, you will likely run into them. – gabe. Feb 10 '11 at 12:39
I routinely set both VISUAL and EDITOR to vim or to vi. If you set them to vi, then ksh will automatically use vi key-bindings for history manipulation. You can link vi to vim (in fact, I thought most installs did this). – Mei Jun 4 '11 at 6:26

You can also make an alias
alias v='vim'
and save it in your /.bashrc

share|improve this answer
This won't work from within 'less'. – pboin Feb 10 '11 at 11:45
@pboin probably like me I totally missed the fact that this was 'in less' on first and several repeat readings. I clarified the question. – xenoterracide Feb 10 '11 at 22:54

Your Answer


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.