vim as default editor on ubuntu/debian

Hello,

I am looking for a way to make vim the default editor on my Ubuntu and Debian based system. Could you help me accomplish this? On the CLI I know that I have to run “update-alternatives --config editor” and then hit 3 for vim. I just dont know if there is a way to have ansible hit 3.

sön 2018-01-21 klockan 16:57 -0800 skrev Joli Martinez:

I am looking for a way to make vim the default editor on my Ubuntu
and Debian based system. Could you help me accomplish this? On the
CLI I know that I have to run "update-alternatives --config editor"
and then hit 3 for vim. I just dont know if there is a way to have
ansible hit 3.

Tried the alternatives[1] module?

- name: Set default editor
  alternatives:
    name: editor
    path: /usr/bin/emacs

// Andreas

[1]: https://docs.ansible.com/ansible/latest/alternatives_module.html

Speaking about that specific case , you can just create/temlate ~/.selected_editor for the user you need.

https://github.com/Voronenko/dotfiles/blob/master/selected_editor

But if you want for all , you can do through

  • name: common | set emacs as default editor
    command: update-alternatives --set editor /usr/bin/emacs
    tags: common