Wikia

Vim Tips Wiki

Changes: Change font

Edit

Back to page

m (add category)
(Update.)
 
(4 intermediate revisions by 4 users not shown)
Line 26: Line 26:
 
</pre>
 
</pre>
   
Make a note of this string. Now put a line in your [[vimrc]] to set guifont to this value, like this:
+
Alternatively, enter the following to insert the current font setting into the buffer:
  +
<pre>
  +
:put =&guifont
  +
</pre>
  +
  +
Now put a line in your [[vimrc]] to set guifont to this value, like this:
 
<pre>
 
<pre>
 
if has('gui_running')
 
if has('gui_running')
Line 33: Line 33:
 
</pre>
 
</pre>
   
Note: If there is a space in the text printed, such as
+
If there is a space in the font name, such as
 
<pre>
 
<pre>
 
guifont=Monospace 10
 
guifont=Monospace 10
 
</pre>
 
</pre>
it will be necessary to escape the space
+
it is necessary to escape the space
 
<pre>
 
<pre>
 
set guifont=Monospace\ 10
 
set guifont=Monospace\ 10
 
</pre>
 
</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==
 
==See also==
Line 46: Line 64:
   
 
==Comments==
 
==Comments==
Am keeping this as a ''simple'' form of [[VimTip632]] for newcomers.
 
----
 
How about for console vimmers? :-(
 
:Console Vim uses whatever font your 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. I believe Vim cannot use a different font than the rest of the terminal. --[[User:Fritzophrenic|Fritzophrenic]] 15:25, July 25, 2011 (UTC)
 
::Indeed. When running inside a terminal, Vim can, at most, change the colours (within the limits of the colours supported by the terminal: sometimes bold and unbold black and white, often 8 colours plus bold/unbold foreground only [or seen another way, 8 background and 16 foreground]; on X11 some terminals support up to 256 background and foreground colours; "changing colours" usually also includes the use of reverse-video), and, if the terminal supports them (not all terminals do, and even those which do may support it only with certain fonts), use bold, underline and/or italic. — [[User:Tonymec|Tonymec]] 05:44, July 26, 2011 (UTC)
 

Latest revision as of 05:41, September 22, 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 VimEdit

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 alsoEdit

CommentsEdit

Around Wikia's network

Random Wiki