# vim as default editor on ubuntu/debian

**URL:** <https://forum.ansible.com/t/vim-as-default-editor-on-ubuntu-debian/26526>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [January 22, 2018, 12:57am UTC](https://forum.ansible.com/t/vim-as-default-editor-on-ubuntu-debian/26526 "2018-01-22T00:57:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joli\_Martinez](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Joli\_Martinez](https://forum.ansible.com/u/Joli_Martinez)\
**Post date:** [January 22, 2018, 12:57am UTC](https://forum.ansible.com/t/vim-as-default-editor-on-ubuntu-debian/26526/1 "2018-01-22T00:57:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [January 22, 2018, 2:33am UTC](https://forum.ansible.com/t/vim-as-default-editor-on-ubuntu-debian/26526/2 "2018-01-22T02:33:08Z")

</div>

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  
&nbsp;&nbsp;alternatives:  
&nbsp;&nbsp;&nbsp;&nbsp;name: editor  
&nbsp;&nbsp;&nbsp;&nbsp;path: /usr/bin/emacs

// Andreas

[1]: [https://docs.ansible.com/ansible/latest/alternatives\_module.html](https://docs.ansible.com/ansible/latest/alternatives_module.html)

---

<div class="post-metadata">

**Author:** ![slavko](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/slavko/32/8869_2.png) [@slavko](https://forum.ansible.com/u/slavko)\
**Post date:** [January 22, 2018, 7:57am UTC](https://forum.ansible.com/t/vim-as-default-editor-on-ubuntu-debian/26526/3 "2018-01-22T07:57:40Z")

</div>

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](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
