Global Configuration of VIM

I want to make global changings in VIM so it is in every cube the same. Where do I have to make the changes? In dom0? vimrc file?

This is an interesting challenge. If all of the appVMs are sourced from the same template, you can make the change in vimrc in that template. If they are not, though… I’m not sure there is a central place where this can be done.

As always, it’s best to do this before you start creating and
configuring qubes.
In that case you can make the change in /etc/skel/.vimrc in the
template, and every qube created afterwards using that template will
pick up the configuration.
If you have already created numerous qubes this wont fly - they already
have their own /home/user and wont be affected by changes to the
template. You must make the change in the individual qubes.

You can do this in salt.
Create /srv/salt/vim in dom0 and create the vimrc file there -
/srv/salt/vim/vimrc

/srv/salt/vim/vim.top

base:
  '*':
    - vim.vim

/srv/salt/vim/vim.sls

vim:
  pkg.installed

/home/user/.vimrc:
  file.managed:
    - source: salt://vim/vimrc

Then:
qubesctl --skip-dom0 --targets=TARGET_LIST state.apply vim.vim

The “top” file is used for targeting - it uses a wildcard * in this
case.
The state file describes what we want - the vim pkg installed, and /home/user/.vimrc
created from the vimrc source file. (pkg.installed will use the
appropriate package manager for the qube you have targeted.)

This is very simple, but fine.
You can leverage salt to deliver different vimrc files to
different qubes, depending on what other packages are installed, or what
tags they have, and to automatically configure vimrc in different places
depending on whether the target is a template or a template based qube.
Make sure you understand the basics before moving on.

4 Likes

Thanks for your support. I will reflect on this and give a try.

Hm, I tried tried now several times to set the .vimrc-file, but I do not succeed. I tried it several times exactly the “salt-way” unman explained.

Any clues where to search the mistake?

If I just want to save the .vimrc in a qube, which directory you recommend (in the home-directory it is not working)?

P.S.: the fine structures of QubesOs are still an enigma for me.

What is the mistake?
What error do you see in the log file? (/var/log/qubes/mgmt-QUBE.log)

From the log-file:

2022-10-12 22:31:15,062 output: Rendering SLS ‘base:vim.vim’ failed: found character that cannot start any token

2022-10-12 22:31:15,062 output: [CRITICAL] Rendering SLS ‘base:vim.vim’ failed: found character that cannot start any token

Do I have to substitute ‘*’ in the .top-file? And what command?

Many problems that people have in Qubes are actually not Qubes specific.
This is one of those.
If you search for that error message (found character that cannot start
any token) you will find a possible solution. Make sure that your sls
files contain spaces, not tabs.
Salt files are written in yaml, and it’s a requirement that they are
laid out using spaces only. Check that.

Thank you, Unman, for your appreciated support.

I removed the tabs and placed correct indents, then it worked. Now the .vimrc file appears in the /home/user directory of the specific qubes and after reboot the configuration is appearing in the editor. Very nice!

As a layman it is often even hard to differentiate if it is a qubes specific problem or not. But I learn and qubes gives me the Internet-security I need, so it is worth the struggles…

Thanks to all developers

1 Like

You can do this by setting system-wide configuration in the template.

For neovim you would do this putting the configuration files in /etc/xdg/nvim/.