I am new to vim, and I want to set the default color theme to obsidian2 (I have already put it into /colors).
In the normal mode, I enter :e $MYVIMRC to open the .vimrc file.
Then I add :colorscheme obsidian2 into the .vimrc file.
After restarting vim, the default color theme does not change.
Any suggestions please?
Edit: I am using MacVim. I also tried setting the $MYGVIMRC, but it doesn't help.
If you add :colorscheme obsidian2, you just change the scheme temporarily.
If you want to change scheme permanently, add config like this in your vimrc file:
set background=dark
colorscheme obsidian2
then reload vimrc.
If you instert :colorscheme obsidian2 to .vimrc file, it's wrong.
You should remove : character like:
colorscheme obsidian2
and restart vim or run :source %
Related
I have used vim for a while now, but after my friend introduced me to gvim, I'm trying to use it now. I have basic vimrc settings of :
set guifont=Monaco:h17
colorscheme zellner
set number
syntax on
I noticed that the settings were applied to my gvim. I want a different colorscheme for gvim and vim as I usually open the files I'll read quickly with vim or vi, and use gvim as my main code editor.
I heard people talk about the .gvimrc file, but I don't have it where my .bashrc, .zshrc, and .vimrc are.
How do I have separate colorschemes for gvim and vim?
Vim doesn't create either ~/.vimrc or ~/.gvimrc for you so you have to create them on your own.
You can either create the missing file in your shell, then edit in Vim:
$ touch ~/.gvimrc
$ vim ~/.gvimrc
<some editing>
:wq
or do everything from Vim:
:e ~/.gvimrc
<some editing>
:wq
Note: ~/.vimrc is still sourced whether you have a ~/.gvimrc or not so your gvimrc can be kept lightweight by only having GUI-specific options and overrides. In your case:
" ~/.vimrc
colorscheme zellner
set number
syntax on
" ~/.gvimrc
set guifont=Monaco:h17
colorscheme slate
You can do it in a single ~/.vimrc:
if has("gui_running")
colorscheme zellner
else
colorscheme blue
endif
See http://vimdoc.sourceforge.net/htmldoc/eval.html#has() and http://vimdoc.sourceforge.net/htmldoc/eval.html#feature-list
I'm wondering why my VIM can't apply the changes I modify in $MYVIMRC. The changes only apply to GVIM instead of VIM. I have the following in $MYVIMRC:
syntax on
colorscheme tomorrow-night
I also tried changing the color scheme setting in the command bar below by typing :colorscheme tomorrow-night but nothing changed. Why is it not changing?
The main difference between Vim and GVim is that GVim is an independent application that does not run in your terminal emulator.
If you use Vim and GVim for different purposes, I recommend you to create also a gvimrc file. But if you want to keep a single vimrc file, you can do something like this:
if has('gui_running')
" GVim
set guifont=Larabiefont\ 13
else
" Vim
set t_Co=256
set termguicolors
endif
colorscheme archery
Notice the set termguicolors in this code. I think this is the most convenient solution nowadays for common issues with colorschemes. It tells Vim to use the true colors defined for GVim with hexadecimal notation in guifg and guibg (instead of ctermfg and ctermbg).
I have a problem trying to retain the colorscheme I want in Vim. I have tried the command
colo colorscheme
colors colorscheme
colorscheme colorscheme
But none of them worked. When I reopened my file, a default colorscheme was still used.
Pic1 is with the default colorscheme
Pic2 is with delek which is the one I want
Pic3 is the screenshot of _vimrc
Thanks guys :)
i starting to use VIM for windows, i download the minimal windows vim exe from here:
http://www.vim.org/download.php#pc
i created simple vimrc file that is located in the gvim.exe directory that looks like this :
vimrc:
set secure exrc
"disable beep
set noeb vb t_vb=
"color scheme
set background=dark
highlight Normal guibg=Black guifg=White
"remove topbar
set guioptions-=T
the thing is that when i execute the gvim.exe , it doesn't load the vimrc
it load it only when from within vim i run :
:e vimrc
:so %
what i missing here ?
Your plugins, colorschemes, etc. are supposed to be here:
%userprofile%\vimfiles
Your vimrc is supposed to be there:
%userprofile%\vimfiles\vimrc
I want to enable cursorline only for gvim but disable it for vim in TUI, I tried this in .vimrc
if has("gui_running")
set cul
else
set nocul
endif
but it doesn't seem to work.
The .vimrc gets read by gvim and vim while the .gvimrc gets only read by gvim. As the docs say:
The gvimrc file is where GUI-specific startup commands should be placed. It
is always sourced after the |vimrc| file. If you have one then the $MYGVIMRC
environment variable has its name.
While your command should do the trick, I'd place the set cul command in my .gvimrc.
This will also help your .vimrc being cleaner and you don't need gui_running checks anymore.