Vim Tips Wiki
(Add subpage to TipProposed to fix link)
(Update.)
Tag: rollback
(16 intermediate revisions by 9 users not shown)
Line 1: Line 1:
  +
{{TipNew
{{TipProposed
 
|id=0
+
|id=1587
|previous=0
+
|previous=1586
|next=0
+
|next=1588
 
|created=February 16, 2008
 
|created=February 16, 2008
 
|complexity=basic
 
|complexity=basic
Line 8: Line 8:
 
|version=7.0
 
|version=7.0
 
|subpage=/200802
 
|subpage=/200802
  +
|category1=Getting started
  +
|category2=
 
}}
 
}}
Within the gui, you can change the font using '''Edit''' -> '''Select Font''', or just use the command
+
In gvim, you can change the font using the '''Edit''' menu, '''Select Font'''. An alternative is to enter the command:
 
<pre>
 
<pre>
:set guifont=*.
+
:set guifont=*
 
</pre>
 
</pre>
   
Once you have a font you like, you'd like to make it the default in the future. Do
+
Once you have a font you like, you want to make it the default in the future. Do
 
<pre>
 
<pre>
 
:set guifont?
 
:set guifont?
 
</pre>
 
</pre>
  +
 
and Vim will display something like
 
and Vim will display something like
 
<pre>
 
<pre>
guifont=Lucida_console:h11.
+
guifont=Lucida_Console:h11
 
</pre>
 
</pre>
Make a note of this string. Now put a line in your .vimrc setting guifont to this value. Done!
 
   
  +
Alternatively, enter the following to insert the current font setting into the buffer:
Note: Do not forget to escape blanks in the font name with <tt>\</tt>
 
  +
<pre>
  +
:put =&guifont
  +
</pre>
   
 
Now put a line in your [[vimrc]] to set guifont to this value, like this:
==Comments==
 
  +
<pre>
  +
if has('gui_running')
  +
set guifont=Lucida_Console:h11
  +
endif
  +
</pre>
   
  +
If there is a space in the font name, such as
----
 
  +
<pre>
  +
guifont=Monospace 10
  +
</pre>
  +
it is necessary to escape the space
  +
<pre>
  +
set guifont=Monospace\ 10
  +
</pre>
  +
  +
The following example shows how vimrc can include settings for more than one operating system, on the assumption that the vimrc file is the same on more than one system. The example also shows how <code>'guioptions'</code>, a color scheme, and the window size can be set.
  +
  +
<pre>
  +
if has('gui_running')
  +
set guioptions-=T " no toolbar
  +
colorscheme elflord
  +
set lines=60 columns=108 linespace=0
  +
if has('gui_win32')
  +
set guifont=DejaVu_Sans_Mono:h10:cANSI
  +
else
  +
set guifont=DejaVu\ Sans\ Mono\ 10
  +
endif
  +
endif
  +
</pre>
  +
  +
==Console Vim==
  +
Console Vim uses whatever font the console/terminal is using. Changing the font in your terminal is done differently depending on your system and the terminal in use. Consult the documentation or manpages for your terminal, or do a web search for how to change the font in your chosen terminal. Vim cannot use a different font than the rest of the terminal.
  +
  +
==See also==
  +
*[[VimTip632|Setting the font in the GUI]] details
  +
 
==Comments==

Revision as of 05:41, 22 September 2014

Tip 1587 Printable Monobook Previous Next

created February 16, 2008 · complexity basic · author Metacosm · version 7.0


In gvim, you can change the font using the Edit menu, Select Font. An alternative is to enter the command:

:set guifont=*

Once you have a font you like, you want to make it the default in the future. Do

:set guifont?

and Vim will display something like

guifont=Lucida_Console:h11

Alternatively, enter the following to insert the current font setting into the buffer:

:put =&guifont

Now put a line in your vimrc to set guifont to this value, like this:

if has('gui_running')
  set guifont=Lucida_Console:h11
endif

If there is a space in the font name, such as

guifont=Monospace 10

it is necessary to escape the space

set guifont=Monospace\ 10

The following example shows how vimrc can include settings for more than one operating system, on the assumption that the vimrc file is the same on more than one system. The example also shows how 'guioptions', a color scheme, and the window size can be set.

if has('gui_running')
  set guioptions-=T  " no toolbar
  colorscheme elflord
  set lines=60 columns=108 linespace=0
  if has('gui_win32')
    set guifont=DejaVu_Sans_Mono:h10:cANSI
  else
    set guifont=DejaVu\ Sans\ Mono\ 10
  endif
endif

Console Vim

Console Vim uses whatever font the console/terminal is using. Changing the font in your terminal is done differently depending on your system and the terminal in use. Consult the documentation or manpages for your terminal, or do a web search for how to change the font in your chosen terminal. Vim cannot use a different font than the rest of the terminal.

See also

Comments