Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Ubuntu 9.10. Whenever I open the gvim application, I have to select a custom font (Edit→Select font). I would like gvim to remember my choice. Perhaps I need to edit the ~/.vimrc file, I am not sure.

How can I make gvim remember my preference?

share|improve this question
up vote 20 down vote accepted

Close. Set the font through the gui, then use the command (: to get the prompt) set gfn? to get the current font string. It should look something like this:

guifont=Mono Uralic 10

Then edit/create ~/.gvimrc and add the line:

set gfn=Mono\ Uralic\ 10

Note: You need to escape the spaces from the output (as I have above)

share|improve this answer
gfn is just shorthand for guifont, so the command could also be set guifont=Mono\ Uralic\ 10. And it works if you put it in .vimrc too. – frabjous Sep 3 '10 at 16:21
@frabjous: gvim, not vim, should be the one to read .gvimrc; so I think a gvim related option belongs to .gvimrc. – ΤΖΩΤΖΙΟΥ Sep 4 '10 at 0:27

Here's an automated approach. (I've also made the code below a plugin.)

Select the font you want to use.

Paste this into Gvim in command mode (to set up the map):

map -- :let @a=&gfn<CR>:e ~/.gvimrc<CR>Go<Esc>"apV:s/ /\\ /g<CR>Iset guifont=

Then type -- (to activate the mapping).

You should now be editing your .gvimrc with your current font set at the bottom. Save the file and open another Gvim to test that it works correctly.

What the mapping does:

  • :let @a=&gfn<CR> Copy the current font setting into our a register
  • :e ~/.gvimrc<CR> Edit our gvimrc (whether it exists or not)
  • Go<Esc> Add a new line to the end of the file
  • "ap Paste the font setting
  • V:s/ /\\ /g<CR> Escape spaces
  • Iset guifont= Put the set variable text before our setting
share|improve this answer

set the font smoothing with 'anti' in your ~/.vimrc

set anti gfn=Ubuntu\ Mono\12,Inconsolata\ 12,\ Envy\ Code\ R\ 10
share|improve this answer
Um. What does your answer have to do with my question? – ΤΖΩΤΖΙΟΥ Oct 13 '10 at 16:32

On Windows, I had to delimit by colon to get it working,

set gfn=Lucida\ Console:h10
share|improve this answer
This is at best a comment, since that colon isn't need on Ubuntu. – muru Sep 16 '15 at 15:12
Its easier to read an answer than a comment. And the answer is specifically for Windows. – Nemo Sep 16 '15 at 16:15
But this site isn't. – muru Sep 16 '15 at 16:25
Maybe, but this is a generic gvim question. – Nemo Sep 16 '15 at 16:34
But your answer isn't. – muru Sep 16 '15 at 16:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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