I have a machine for which when I run fc it opens in the nano editor. How can I switch the editor to vim when I edit a command with fc?

3 Answers 3


If your shell follow the POSIX standard, the fc command will use the variable FCEDIT as the editor.

Setting FCEDIT in your shell's initialisation files will make the built-in fc command use the indicated editor in any new shell sessions:


You may also specify an editor with fc -e vim.

  • There is no need to export this. It is used by the shell internally only.
    – schily
    Jun 8, 2018 at 8:58
  • @schily Unless fc is an external command.
    – Kusalananda
    Jun 8, 2018 at 8:59
  • fc cannot be an external command as it works on internal data structures of the shell. It is a hack to do some primitive history editing using an external editor instead of implementing a real history editor in the shell. BTW: I implemented a prototype of an integrated history editor in 1982 and the first shell with fully integrated history editing under cursor control in 1984. The Korn Shell introduced fc in 1983 and a real history editor in 1986. Using fc today looks like an anachronism. I am used to have an integrated history editor in the shell since 34 years...
    – schily
    Jun 8, 2018 at 9:05
  • @schily When pondering how I would implement fc as an external command, I realise that you may well be correct. I use fc daily, but mostly through alias r='fc -s', and only rarely to actually edit old commands.
    – Kusalananda
    Jun 8, 2018 at 9:10
  • The shell I used in 1984 is called bsh and has been written at H.Berthold AG. It is not a Bourne like shell but rather similar to csh but still closer to sh than csh. I never had the need for something like fc and I only implemented it in the Bourne Shell (bosh) , see schilytools.sourceforge.net/bosh.html because the author of the POSIX test suite claims that XSI support is needed for compliance unless you like to write only a shell for an embedded system. dash identifies as such a shell. It has no editor and no multi byte support.
    – schily
    Jun 8, 2018 at 9:29

Just add to your /etc/profile following line, then log out and in again to make changes take affect.

export EDITOR=vim
  • I use it with bash. Jun 8, 2018 at 6:50
  • 1
    Ah, yes, bash seems to use EDITOR if FCEDIT is unset, but not in POSIX mode.
    – Kusalananda
    Jun 8, 2018 at 6:53

On Debian and Ubuntu:

sudo update-alternatives --config editor

You must log in to answer this question.

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