Linux changing vimrc theme color with alias

0

I recently started running Ubuntu 12.04 on an Oracle VM VirtualBox 4.3.6 and I'm really liking it. I managed to install the Solarized theme and I used sigurdga's gnome-terminal-colors-solarized to make the terminal colors work with vim.

Recently I've discovered that I like the dark theme in some situations and the light theme in others, and so I've aliased a command to run the ./solarized executable in sigurdga's repo. However, I've noticed that I have to manually change the .vimrc set background = light value between light and dark. I was wondering if I could alias my solarize command to toggle the background value in .vimrc as I toggle the terminal colors?

Alternatively, if you think I have an awful setup please show me how to make it better!

Thanks in advance!

A.Wan

Posted 2014-02-02T19:38:39.383

Reputation: 101

I don't use solarized but normally set background=light (or dark) should be set in the color scheme it self. There should be no reason to set it manually in your vimrc. (You can also always just add a sed command to change the value from light to dark when you run your solarized script) – FDinoff – 2014-02-02T21:51:12.820

1I don't understand your situation well enough to propose a concrete answer, but there are a couple of approaches you can take. One is to have your ~/.vimrc determine your preferred 'background' from the environment, assuming that the "situations" you referred to have some differentiable aspect to their environments. Another is to include the 'background' setting as part of the alias you use in each situation. From the command line, you can set the values of Vim options and you can call functions if simply setting an option isn't sufficient. – garyjohn – 2014-02-02T22:26:05.007

Answers

0

Drop the explicit setting from your ~/.vimrc and instead pass it to Vim in your alias definitions, e.g.:

$ alias darkvim='vim --cmd "set background=dark"'

Similar customizations can be done by setting a variable (--cmd "let g:myvar = '...'") and evaluating it in your .vimrc.

Ingo Karkat

Posted 2014-02-02T19:38:39.383

Reputation: 19 513