# Pushing System-Wide Vim Configuration Changes Across Multiple VMs/Desktops

**URL:** <https://community.learnlinux.tv/t/pushing-system-wide-vim-configuration-changes-across-multiple-vms-desktops/972>\
**Category:** Linux on Servers\
**Created:** [October 9, 2021, 12:45am UTC](https://community.learnlinux.tv/t/pushing-system-wide-vim-configuration-changes-across-multiple-vms-desktops/972 "2021-10-09T00:45:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GraysonPeddie](https://community.learnlinux.tv/user_avatar/community.learnlinux.tv/graysonpeddie/32/352_2.png) [@GraysonPeddie](https://community.learnlinux.tv/u/GraysonPeddie)\
**Post date:** [October 9, 2021, 12:45am UTC](https://community.learnlinux.tv/t/pushing-system-wide-vim-configuration-changes-across-multiple-vms-desktops/972/1 "2021-10-09T00:45:27Z")

</div>

While setting up my Debian Linux container, I needed to make changes to Vim system-wide instead of per-user. So I went ahead and removed everything from `/etc/vim/vimrc` and add my own settings:

```auto
set mouse-=

```

I saved and reopened the same file and I still get the mouse pointer. Inside vim, I can do `set mouse-=a` which tells Vim not to interact with my mouse, however, I want to make it permanent regardless of the user. So `set mouse-=` does nothing. I then tried:

```auto
set mouse-=a

```

…and that won’t do it either.

```auto
set mouse=

```

…still won’t do it either, so I was out of luck until I found this thread in Github:

> <https://github.com/vim/vim/issues/2042>
>
> If ~/.vimrc doesn't exist, some configs in /etc/vimrc has no effect. E.g.
> \`set …scrolloff=\<n\>\`
> 
> Some configs changes the behaviour. E.g.
> \`highlight Todo\`
> doen't work. I have to use
> \`highlight cTodo\`
> 
> These configs works after I create an empty ~/.vimrc file.
> 
> 
> Version Information:
> \`\`\`
> VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Aug 24 2017 18:10:32)
> Included patches: 1-987
> Compiled by root@dj
> Huge version without GUI. Features included (+) or not (-):
> +acl +file\_in\_path +mouse\_sgr +tag\_old\_static
> +arabic +find\_in\_path -mouse\_sysmouse -tag\_any\_white
> +autocmd +float +mouse\_urxvt +tcl
> \-balloon\_eval +folding +mouse\_xterm +termguicolors
> \-browse -footer +multi\_byte -terminal
> ++builtin\_terms +fork() +multi\_lang +terminfo
> +byte\_offset +gettext -mzscheme +termresponse
> +channel -hangul\_input +netbeans\_intg +textobjects
> +cindent +iconv +num64 +timers
> \-clientserver +insert\_expand +packages +title
> \-clipboard +job +path\_extra -toolbar
> +cmdline\_compl +jumplist +perl +user\_commands
> +cmdline\_hist +keymap +persistent\_undo +vertsplit
> +cmdline\_info +lambda +postscript +virtualedit
> +comments +langmap +printer +visual
> +conceal +libcall +profile +visualextra
> +cryptv +linebreak +python +viminfo
> +cscope +lispindent -python3 +vreplace
> +cursorbind +listcmds +quickfix +wildignore
> +cursorshape +localmap +reltime +wildmenu
> +dialog\_con +lua +rightleft +windows
> +diff +menu +ruby +writebackup
> +digraphs +mksession +scrollbind -X11
> \-dnd +modify\_fname +signs -xfontset
> \-ebcdic +mouse +smartindent -xim
> +emacs\_tags -mouseshape +startuptime -xpm
> +eval +mouse\_dec +statusline -xsmp
> +ex\_extra +mouse\_gpm -sun\_workshop -xterm\_clipboard
> +extra\_search -mouse\_jsbterm +syntax -xterm\_save
> +farsi +mouse\_netterm +tag\_binary      
> system vimrc file: "/etc/vimrc"
> user vimrc file: "$HOME/.vimrc"
> 2nd user vimrc file: "~/.vim/vimrc"
> user exrc file: "$HOME/.exrc"
> defaults file: "$VIMRUNTIME/defaults.vim"
> fall-back for $VIM: "/usr/share/vim"
> Compilation: gcc -c -I. -Iproto -DHAVE\_CONFIG\_H -g -O2 -U\_FORTIFY\_SOURCE -D\_FORTIFY\_SOURCE=1       
> Linking: gcc -L. -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.16.2/x86\_64-linux-thread-multi/CORE -L/usr/local/lib -Wl,--as-needed -o vim -lm -lncurses -lelf -lnsl -lacl -lattr -lgpm -ldl -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.16.2/x86\_64-linux-thread-multi/CORE -fstack-protector -L/usr/local/lib -L/usr/lib/perl5/5.16.2/x86\_64-linux-thread-multi/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -L/usr/lib64 -ltcl8.5 -ldl -lpthread -lieee -lm -Wl,-R -Wl,/usr/lib64 -L/usr/lib64 -lruby -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib64
> \`\`\`

I scrolled down to the third post made by “djddjd” and I came across the setting, which is `let skip_defaults_vim = 1`

So I added that to the top of the file.

```auto
let skip_defaults_vim = 1
set mouse=

```

And now I get the insertion cursor instead of the mouse pointer so that I can select text without triggering Vim’s visual mode. If I remove `set mouse=` line from the /etc/vimrc file, the behavior is the same with the insertion cursor still over the terminal. Of course, inserting `set mouse=a` is the same as removing the `let skip_defaults_vim = 1` line from the vimrc file.

```auto
let skip_defaults_vim = 1
set mouse=a

```

Because I do not need the visual mode, I can just delete the `set mouse=` line.

Now here’s the problem. Once I add `let skip-defaults_vim = 1`, Vim started to behave similar to Vi.

- A = Down
- B = Up
- C = Right
- D = Left
- Backspace = Nothing. Vim won’t erase text.

As the thread is about how to push my own default settings system-wide across multiple virtual machines, here’s my question: how do I get it so that I can erase text and use arrow keys so that Vim won’t behave like Vi?

And now here’s my main question: what would be the good way of pushing changes to Vim across multiple virtual machines regardless of users?

I’m not concerned with overriding users’ .vimrc behavior as I want the changes to be global across all Linux VMs. This includes Debian, Ubuntu, Arch, Fedora, and several other Linux distributions, so I want my changes to be distro-agnostic.

I am handy with Linux as I have Ansible setup and ready to go; however, I have not written a playbook yet. I have watched Ansible videos from LearnLinuxTV’s YouTube channel since 2 years ago, but I will have to rewatch it again as my knowledge of it has gotten rusty.

Should I use Ansible or Git for pushing vimrc changes? Some distributions put vimrc in /etc/ while others put vimrc in /etc/vim/ directory, so I do not know how that would work with Git.

Anyway, please pardon me if my thread has gotten too long with a wall of text. Basically, I need to push my own Vim settings regardless of which Linux distribution is running in a virtual machine.

Update: I also lost syntax highlighting by telling Vim to skip the entire default configuration. If I don’t tell Vim to skip default configuration, the `set mouse` command will still get overridden by the defaults. I do not like this behavior.

Update 2: Okay, with the exception of pushing changes for Vim across multiple VMs automatically, here are the settings that will restore syntax highlighting, use of backspace, and arrow keys:

```auto
let skip_defaults_vim = 1
set mouse=
syntax on
set backspace=indent,eol,start
set nocompatible

```

I’ll just leave it there in case others might find useful, although this could have been a separate topic. I just had to do a couple of Google searches in the Internet.

---

<div class="post-metadata">

**Author:** ![Mr\_McBride](https://community.learnlinux.tv/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@Mr\_McBride](https://community.learnlinux.tv/u/Mr_McBride)\
**Post date:** [October 9, 2021, 1:15pm UTC](https://community.learnlinux.tv/t/pushing-system-wide-vim-configuration-changes-across-multiple-vms-desktops/972/2 "2021-10-09T13:15:47Z")

</div>

Good find, thanks for sharing.

---

<div class="post-metadata">

**Author:** ![GraysonPeddie](https://community.learnlinux.tv/user_avatar/community.learnlinux.tv/graysonpeddie/32/352_2.png) [@GraysonPeddie](https://community.learnlinux.tv/u/GraysonPeddie)\
**Post date:** [October 15, 2021, 2:41am UTC](https://community.learnlinux.tv/t/pushing-system-wide-vim-configuration-changes-across-multiple-vms-desktops/972/3 "2021-10-15T02:41:22Z")

</div>

**Solved!**

Okay. In order to refresh my memory regarding Ansible, I had to watch the Ansible tutorials by @jay even though I did play with Ansible last year (thanks for the tutorial regarding Ansible). This is what I have so far.

**~/ansible/inventory**

```auto
[debian]
172.20.1.3:[REDACTED]
172.20.1.4:[REDACTED]
172.20.30.4:[REDACTED]
localhost ansible_connection=local

[archlinux]
172.20.1.8:[REDACTED]

```

**~/ansible/ansible.cfg**

```auto
[defaults]
inventory = inventory
private_key_file = ~/.ssh/ansible

```

**~/ansible/update\_vim.yml**

```auto
---

- hosts: archlinux
  become: true
  tasks:
  - name: install vim in Arch Linux if not installed
    pacman:
      name: vim
      state: present
  - name: update vim file as root in Arch Linux desktop.
    copy:
      src: ~/ansible/files/vimrc
      dest: /etc/vimrc

- hosts: debian
  become: true
  tasks:
  - name: install vim if not installed in Debian.
    apt:
      name: vim
  - name: update vim file as root in Debian servers.
    copy:
      src: ~/ansible/files/vimrc
      dest: /etc/vim/vimrc

```

**~/ansible/files/vimrc**

```auto
let skip_defaults_vim = 1
set mouse=
syntax on
set backspace=indent,eol,start
set nocompatible

```

**Result and Summary**

And now everything should work.

Oh, and I forgot to mention for those who came across this thread and are curious about the copy module. You can assign `owner`, `group`, and `mode` to a destination file you want to copy to. The `mode` is the file permission such as `0644` (“0” is no special permissions such as sticky or setuid/setgid, “644” is for read/write for user, read for group, and read for “other.” “1” is execute for the last three digits and “2” is for write.

Hope that helps!
