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!

  • 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 Feb 2 '14 at 21:51
  • 1
    I 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 Feb 2 '14 at 22:26
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.