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:
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:
…and that won’t do it either.
…still won’t do it either, so I was out of luck until I found this thread in Github:
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.
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.
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:
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.