LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Setting font for gVim (https://www.linuxquestions.org/questions/linux-software-2/setting-font-for-gvim-364719/)

daihard 09-18-2005 10:35 PM

Setting font for gVim
 
Hi.

I'm having trouble setting the GUI font for gVim. I hope someone can help me out.

I set the following in my ~/.vimrc file:
Code:

set guifont="Luxi Mono 9"
However, when I invoke gVim, it does not use that font. The "set guifont" command should also return "Luxi Mono 9," but it comes back blank.

Strangely, if I specify the same font through the command-line parameter, such as gvim -font="Luxi Mono 9", then gVim uses the appropriate font. The "set guifont" command returns the correct font name ("Luxi Mono 9"), too.

What am I doing wrong? Everything else I have in ~/.vimrc is working fine.

I would appreciate any help.

Dai

macemoneta 09-19-2005 03:08 PM

I think you want to put the setting in the ~/.gvimrc which get executed when the GUI is started.

daihard 09-20-2005 12:18 AM

Quote:

Originally posted by macemoneta
I think you want to put the setting in the ~/.gvimrc which get executed when the GUI is started.
Hi.

Thanks for the response. I tried that too, but it did not work either. :confused:

Anything else that you can think of?

Thanks again,
Dai

macemoneta 09-20-2005 12:38 AM

Got it. Remove the quotes. The command should be:

set guifont=Luxi Mono 9

When I tried with the quotes, it was ignored.

daihard 09-20-2005 01:27 AM

Quote:

Originally posted by macemoneta
Got it. Remove the quotes. The command should be:

set guifont=Luxi Mono 9

When I tried with the quotes, it was ignored.

Thanks for the suggestion. I actually tweaked it a bit to get it working. Let me explain...

You were right about the quotes being ignored. However, the above syntax with no quotes gave an error like this:
Code:

Error detected while processing /home/dtoyama/.vimrc:
line    7:
E518: Unknown option: Mono

So instead of using quotes, I preceded each white space with a backslash, like this:
Code:

set guifont=Luxi\ Mono\ 9
That worked. :)

slackie1000 09-20-2005 02:44 AM

hi there,
i would like to link this tip to this thread.
it is a really complete information about setting font for vim in gui mode.
regards,
slackie1000

sorin25 09-20-2005 03:17 AM

Or, you can use xfontsel to get a compatible font description.
This is one description for Luxi Mono
Code:

-*-luxi mono-medium-r-normal--17-120-*-100-*-0-microsoft-cp1252

daihard 09-20-2005 03:39 AM

Quote:

Originally posted by sorin25
Or, you can use xfontsel to get a compatible font description.
This is one description for Luxi Mono
Code:

-*-luxi mono-medium-r-normal--17-120-*-100-*-0-microsoft-cp1252

Care to show me how to obtain the X11-type font description from a font name? :)

windhair 10-07-2005 05:09 AM

This doesnt work in my vim 6.1 kde.
:set guifont=6x12 works
but it what I write in .gvimrc set guifont=6x12 seems have no effect.
what should I do?

daihard 10-07-2005 11:09 AM

Quote:

Originally posted by windhair
This doesnt work in my vim 6.1 kde.
:set guifont=6x12 works
but it what I write in .gvimrc set guifont=6x12 seems have no effect.
what should I do?

I have my guifont variable defined in ~/.vimrc, not in ~/.gvimrc. It should not matter, but it may be worth trying...

windhair 11-24-2005 02:49 AM

Thing not getting solved yet.
I thought I have a solution for the problem, but it doesnt.
What I used in is
Code:

autocmd BufEnter *.for source $HOME/.vimrcfor
And in the .vimrcfor I just add a line "set guifont=6x12".
It works well.
It seems that "set guifont" in .vimrc works only after the "source" or directly input with :set guifont=... after gvim startup, but no effect if I set it in .vimrc . And the other command in .vimrc work well, such as set hlsearch....

I dont'n know why? Can anyone give a hand?

Ygrex 11-24-2005 03:48 AM

You can use /etc/vim/vimrc.local too. But firstly, I do not know why, but you
should to comment the logical structure in the /usr/share/vim/vimrc. Last three
lines in it must be:
Code:

"if filereadable('/etc/vim/vimrc.local')
source! /etc/vim/vimrc.local
"endif

so that file will be executed anyway. Then you can add anything into above
local rc file.

windhair 11-24-2005 04:17 AM

It doesnt work.

BTW. I installed Latex vim Suite, but the guifont neither works for latex nor for other type files.

Ygrex 11-24-2005 04:32 AM

It works when you run the command by your hands, right? The 'source!' command
(by default in vimrc it does not contains exclamation point, did you add it?)
does exactly the same things, like you type them by yourself just after vim
runs. Did you add the char ':' in the begining of your local script line?

hw-tph 11-24-2005 04:43 AM

Quote:

Originally posted by sorin25
Or, you can use xfontsel to get a compatible font description.
This is one description for Luxi Mono
Code:

-*-luxi mono-medium-r-normal--17-120-*-100-*-0-microsoft-cp1252

That will only work with gvim compiled against gtk+1.x. For gtk+2.x you need to use fontconfig names (i.e. "set guifont=CodingFontTobi1_euro\ 12").


Håkan


All times are GMT -5. The time now is 09:30 PM.