Tuesday, March 24, 2020

Customize vim for YAML

I'm doing some Ansible work (on RHEL 8), so I want the YAML configs for vim.  I have a yaml.vim file containing the syntax/etc, and a ~/.vimrc file:

autocmd BufNewFile,BufRead *.yaml,*.yml so ~/.vim/yaml.vim
autocmd FileType yaml,yml set ai ts=2 sw=2 et number

While logged in as user ansible, that worked just peachy.  But then I copied the same files to the same places under ~ (root), and when I was root (via su or su -), vim was clueless about yaml.

I tried changing the ~root/.vim/yaml.vim in .vimrc to ~root/.vim/yaml.vim -- no joy.

With some digging I discovered that vi doesn't read .vimrc when you're root but vim does!!??  But vim didn't work either.

Out of exasperation I tried rebooting my Linux server.  Now it doesn't work for user ansible either!!??

I tried :source ~/.vimrc and it kinda worked.  That picked up the .vimrc settings but not the syntax-highlight stuff in yaml.vim, even if I did a :e! to force it to re-read the file and see the file suffix.  But that only worked for root!?  And only a few times.  Now it doesn't work.  :source ~/.vim/yaml.vim doesn't do anything either.

Help?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/3c40a249-9481-4532-a283-4b13ad49d9df%40googlegroups.com.

No comments:

Post a Comment