Vim-default-editor in coreos

Hi! Fedora CoreOS comes with nano as default text editor.

$ rpm -q nano-default-editor
nano-default-editor-6.0-2.fc36.noarch
$ echo $EDITOR
/usr/bin/nano

is it possible to replace that with vim?

$ sudo rpm-ostree uninstall nano-default-editor                                                                                                                       
error: Package/capability 'nano-default-editor' is not currently requested
$ sudo rpm-ostree install vim-default-editor                                                                                                                        
Checking out tree 977c43d... done
Enabled rpm-md repositories: fedora-cisco-openh264 fedora-modular updates-modular updates fedora updates-archive
Importing rpm-md... done
rpm-md repo 'fedora-cisco-openh264' (cached); generated: 2022-04-07T16:52:38Z solvables: 4
rpm-md repo 'fedora-modular' (cached); generated: 2022-05-04T21:12:01Z solvables: 825
rpm-md repo 'updates-modular' (cached); generated: 2022-06-14T02:11:42Z solvables: 1155
rpm-md repo 'updates' (cached); generated: 2022-07-04T01:12:42Z solvables: 15500
rpm-md repo 'fedora' (cached); generated: 2022-05-04T21:16:11Z solvables: 67992
rpm-md repo 'updates-archive' (cached); generated: 2022-07-04T02:32:07Z solvables: 18129
Resolving dependencies... done
error: Could not depsolve transaction; 1 problem detected:
 Problem: conflicting requests
  - package nano-default-editor-6.0-2.fc36.noarch conflicts with system-default-editor provided by vim-default-editor-2:8.2.5172-1.fc36.noarch
  - package vim-default-editor-2:8.2.5172-1.fc36.noarch conflicts with system-default-editor provided by nano-default-editor-6.0-2.fc36.noarch
  - package nano-default-editor-6.0-2.fc36.noarch conflicts with system-default-editor provided by vim-default-editor-2:8.2.4621-1.fc36.noarch
  - package vim-default-editor-2:8.2.4621-1.fc36.noarch conflicts with system-default-editor provided by nano-default-editor-6.0-2.fc36.noarch
  - package nano-default-editor-6.0-2.fc36.noarch conflicts with system-default-editor provided by vim-default-editor-2:8.2.4845-1.fc36.noarch
  - package vim-default-editor-2:8.2.4845-1.fc36.noarch conflicts with system-default-editor provided by nano-default-editor-6.0-2.fc36.noarch

Cheers

Hi, we have some docs on this here.

2 Likes

I do remember some joke, although I don’t remember it exactly, about a sysadmin logging into a Debian box and finding there was no vi, only nano, and trying to figure out how to exit it. Fedora, like many others, becomes more and more like Windows. I guess that RH figures it’s for the best, and as they’re a billion dollar company, they may be right–I used to complain about such things, but now I feel like the old man yelling at the cloud. Sigh.

1 Like

hmm so I put EDITOR=vi to avoid installing any extra package, it works almost perfectly.

When running sudo systemctl edit it still run nano.

You could use sudo -E

On regular F36,I use neovim so I ended up adding the below to the sudoers file
Defaults env_keep += "EDITOR"

ok i go with

storage:
  files:
    - path: /etc/profile.d/zz-default-editor.sh
      overwrite: true
      contents:
        inline: |
          export EDITOR=vi
    - path: /etc/sudoers.d/editor
      overwrite: true
      contents:
        inline: |
          Defaults env_keep += "EDITOR"
      mode: 0440

and the hope to see vi instead of nano everywhere.
Thanks!

1 Like

On most systems you can replace the default editor.
dnf swap nano-default-editor vim-default-editor --allowerasing which would remove nano and install vim as the default editor.

Note that Fedora CoreOS doesn’t have dnf.

Have not worked with CoreOS, so did not know that.

But it does have rpm correct.?
Maybe that could then be done with a similar rpm command to remove the nano default editor and install the vim default editor.

This was super useful, thank you very much!