Vim Tips Wiki
(→‎Comments: bad advice)
Tag: sourceedit
(15 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{review}}
 
 
{{TipImported
 
{{TipImported
 
|id=1036
 
|id=1036
 
|previous=1035
 
|previous=1035
|next=1037
+
|next=1041
|created=November 1, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=vineeth
 
|author=vineeth
Line 12: Line 11:
 
|category2=
 
|category2=
 
}}
 
}}
In gvim, sometimes we change the default color scheme (say to morning), but the next time we start gvim, the setting will be lost.
+
In gvim, after changing the default color scheme, the next time gvim is started, the default setting is restored.
   
One way to retain this is by adding the following line in your vimrc <tt>:colorscheme ''&lt;scheme_name&gt;''</tt>
+
To retain the color scheme add <code>colorscheme ''<scheme_name>''</code> to <code>vimrc</code>.
   
 
For example:
 
For example:
Line 22: Line 21:
   
 
==Comments==
 
==Comments==
  +
MS Windows: By default Vim calculates the <code>HOME</code> directory as <code>%HOMEDIR%%HOMEPATH%</code>. If this is not the location you want, make sure <code>HOME</code> exists and is set to where your <code>vimrc</code> file is located. The <code>$HOME</code> environment variable can be set by going to your desktop, right click on "My Computer", click the "Advanced" tab, select "Environment Variables". If <code>HOME</code> is not in the list of variables, create a new variable named HOME and point it to the location of your vimrc. This is normally <code>C:\Documents And Settings\<USERNAME></code> and you'll have to create <code>vimfiles\colors</code> and put your new colorscheme in this folder.
This works for me on Windows. Make sure your "HOME" environment variable exists and is set to where your vimrc file is located.
 
   
 
On Unix/Linux/MacOSX this should be preset and can be seen by going to a command prompt/Terminal window and typing <code>echo $HOME</code> or in vim enter <code>:echo $HOME</code>.
----
 
On Windows, the $HOME environment variable can be set by going to your desktop, right click on "My Computer", click the "Advanced" tab, select "Environment Variables". If HOME is not in the list of variables, create a new variable named HOME and point it to the location of your vimrc.
 
 
On Unix/Linux/MacOSX this should be set automatically and can be easily seen by going to a command propt/Terminal window and typing "echo $HOME".
 
   
 
----
 
----
Noticed one thing about <tt>:colorscheme &lt;colorscheme&gt;</tt> not working, if you have a gvimrc file and are having trouble getting your colorscheme to load properly on startup, edit your gvimrc file and comment out or remove the lines containing highlight.
+
Sometimes if <code>colorscheme <colorscheme></code> is not loading properly on startup, edit your <code>gvimrc</code> file and comment out or remove the lines containing <code>highlight</code> aka <code>hi</code>.
   
Save your changes and restart Vim, your colorscheme should now load.
+
Save your changes and start vim.
   
 
----
 
----
You can set your preferred color scheme in gvim for Windows by editing the file vimrc. This file you can find in "C:\Program Files\Vim" or other location where you have installed Vim.
+
You can set your preferred color scheme in gvim for MS Windows by editing the file <code>_vimrc</code> in <code>C:\Program Files\Vim</code> or the location where you installed Vim.
  +
:This is bad advice; you should place your [[vimrc]] in your home directory, as noted in the other comments here. Putting anything in Program Files will risk all your changes being lost any time you install a new version of Vim, and additionally it will affect all uses instead of just your login. --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 17:34, June 24, 2015 (UTC)
   
Then just open the vimrc file and add a line like colors &lt;your favourite color scheme&gt; as the last line. For example:
+
Edit <code>_vimrc</code> and add a line like <code>colors <your color scheme></code> as the last line. For example:
   
 
<pre>
 
<pre>
Line 43: Line 40:
 
</pre>
 
</pre>
   
Then save the file and start your gvim you can see your favourite color scheme in starting itself.
+
Save the file and start gvim you will see your color scheme.
   
 
----
 
----
When using Windows (this particular example applies to any instance of gvim), you will see at {{help|gvimrc}} that for Win32 if it's not in $HOME, you may file _gvimrc in $VIM. You may display these variables by issuing, ":echo $VIM", or ":echo $HOME", and you will know exactly what you are dealing with.
+
MS Windows: (this particular example applies to any instance of gvim), {{help|gvimrc}} states that for MS Win32 if <code>vimrc</code> is not in <code>$HOME</code>, the _gvimrc in $VIM. You may display these by issuing, <code>:echo $VIM</code>, or <code>:echo $VIM</code> from within <code>gvim</code>.
   
 
----
 
----
  +
See also [[Switch_color_schemes]], [[Color highlighting on telnet]], [[Use the console colors in gvim]]
   
What this discussion fails to point out is that you should place your color scheme files in ~/.vim/colors
 
 
I had to go looking elsewhere to chase that down.
 
 
----
 
   
  +
[[User:DG12|DG12]] 18:59, December 6, 2009 (UTC)
[[One page summary of color schemes]]
 

Revision as of 17:34, 24 June 2015

Tip 1036 Printable Monobook Previous Next

created 2005 · complexity basic · author vineeth · version 6.0


In gvim, after changing the default color scheme, the next time gvim is started, the default setting is restored.

To retain the color scheme add colorscheme <scheme_name> to vimrc.

For example:

colorscheme morning

Comments

MS Windows: By default Vim calculates the HOME directory as %HOMEDIR%%HOMEPATH%. If this is not the location you want, make sure HOME exists and is set to where your vimrc file is located. The $HOME environment variable can be set by going to your desktop, right click on "My Computer", click the "Advanced" tab, select "Environment Variables". If HOME is not in the list of variables, create a new variable named HOME and point it to the location of your vimrc. This is normally C:\Documents And Settings\<USERNAME> and you'll have to create vimfiles\colors and put your new colorscheme in this folder.

On Unix/Linux/MacOSX this should be preset and can be seen by going to a command prompt/Terminal window and typing echo $HOME or in vim enter :echo $HOME.


Sometimes if colorscheme <colorscheme> is not loading properly on startup, edit your gvimrc file and comment out or remove the lines containing highlight aka hi.

Save your changes and start vim.


You can set your preferred color scheme in gvim for MS Windows by editing the file _vimrc in C:\Program Files\Vim or the location where you installed Vim.

This is bad advice; you should place your vimrc in your home directory, as noted in the other comments here. Putting anything in Program Files will risk all your changes being lost any time you install a new version of Vim, and additionally it will affect all uses instead of just your login. --Fritzophrenic (talk) 17:34, June 24, 2015 (UTC)

Edit _vimrc and add a line like colors <your color scheme> as the last line. For example:

colors koehler

Save the file and start gvim you will see your color scheme.


MS Windows: (this particular example applies to any instance of gvim), :help gvimrc states that for MS Win32 if vimrc is not in $HOME, the _gvimrc in $VIM. You may display these by issuing, :echo $VIM, or :echo $VIM from within gvim.


See also Switch_color_schemes, Color highlighting on telnet, Use the console colors in gvim


DG12 18:59, December 6, 2009 (UTC)