Quantcast

How to change font on the fly?

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to change font on the fly?

Dotan Cohen
Depending on what I am editing, I sometimes prefer a fixed-width font
and other tiems a proportional font. My previous editor, Kate (KDE
Advanced Text Editor) lets the user change the font on the fly. Can
VIM do this, or is playing with the config file (thus requiring a
restart) the only way?

Thanks in advance!

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Teemu Likonen
* 2010-02-19 11:04 (+0200), Dotan Cohen wrote:

> Depending on what I am editing, I sometimes prefer a fixed-width font
> and other tiems a proportional font. My previous editor, Kate (KDE
> Advanced Text Editor) lets the user change the font on the fly. Can
> VIM do this, or is playing with the config file (thus requiring a
> restart) the only way?

Unfortunately proportional fonts don't work that well in Vim but at
least changing font interactively is easy:

    set guifont=*

You can set a certain font by using font name instead of "*".

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Christian Brabandt
Hi Teemu!

On Fr, 19 Feb 2010, Teemu Likonen wrote:

> * 2010-02-19 11:04 (+0200), Dotan Cohen wrote:
>
> > Depending on what I am editing, I sometimes prefer a fixed-width font
> > and other tiems a proportional font. My previous editor, Kate (KDE
> > Advanced Text Editor) lets the user change the font on the fly. Can
> > VIM do this, or is playing with the config file (thus requiring a
> > restart) the only way?
>
> Unfortunately proportional fonts don't work that well in Vim but at
> least changing font interactively is easy:
>
>     set guifont=*
>
> You can set a certain font by using font name instead of "*".

Yes and you can even manipulate the setting on the fly. For example I
have this in my .vimrc:
if  has("gui_running") && (has("win32") || has("win64"))
    nnoremap <C-Up> :silent let &guifont=substitute(&guifont, ':h\zs\d\+', '\=submatch(0)+1', '')<CR>
    nnoremap <C-Down> :silent let &guifont=substitute(&guifont, ':h\zs\d\+', '\=submatch(0)-1', '')<CR>
endif

which allows to increase/decrease my font size by using Ctrl+Up/Down.
This only works for Windows, as other guis have possibly a different
value for the option guifont, therefore this is wrapped into the test
for Windows and a running GUI.


regards,
Christian

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
In reply to this post by Teemu Likonen
> Unfortunately proportional fonts don't work that well in Vim but at
> least changing font interactively is easy:
>
>    set guifont=*
>
> You can set a certain font by using font name instead of "*".
>

Thanks. When I use names that I suspect (such as Tahoma, which is an
installed font) nothing happens. How can I find a list of valid font
names? I'm on Kubuntu 9.10. Thanks.

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
In reply to this post by Christian Brabandt
On 19 February 2010 13:16, Christian Brabandt <[hidden email]> wrote:

> Hi Teemu!
>
> On Fr, 19 Feb 2010, Teemu Likonen wrote:
>
>> * 2010-02-19 11:04 (+0200), Dotan Cohen wrote:
>>
>> > Depending on what I am editing, I sometimes prefer a fixed-width font
>> > and other tiems a proportional font. My previous editor, Kate (KDE
>> > Advanced Text Editor) lets the user change the font on the fly. Can
>> > VIM do this, or is playing with the config file (thus requiring a
>> > restart) the only way?
>>
>> Unfortunately proportional fonts don't work that well in Vim but at
>> least changing font interactively is easy:
>>
>>     set guifont=*
>>
>> You can set a certain font by using font name instead of "*".
>
> Yes and you can even manipulate the setting on the fly. For example I
> have this in my .vimrc:
> if  has("gui_running") && (has("win32") || has("win64"))
>    nnoremap <C-Up> :silent let &guifont=substitute(&guifont, ':h\zs\d\+', '\=submatch(0)+1', '')<CR>
>    nnoremap <C-Down> :silent let &guifont=substitute(&guifont, ':h\zs\d\+', '\=submatch(0)-1', '')<CR>
> endif
>
> which allows to increase/decrease my font size by using Ctrl+Up/Down.
> This only works for Windows, as other guis have possibly a different
> value for the option guifont, therefore this is wrapped into the test
> for Windows and a running GUI.
>
>

Interesting. I am interested in changing font size on the fly (bad
eyes) and I just assumed that this was possible. I am new to VIM and
not had the chance to try everything yet.

On my Kubuntu 9.10 machine I tried entering the following into the command bar:
:silent let &guifont=substitute(&guifont, ':h\zs\d\+', '\=submatch(0)+1', '')

It gave  no error, but the font size did not change. Where in the vast
fine manual should I start looking for how to perform this necessary
task in Linux?

Thanks!
--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Christian Brabandt
Hi Dotan!

On Fr, 19 Feb 2010, Dotan Cohen wrote:

> It gave  no error, but the font size did not change. Where in the vast

Is that gvim? What does
:echo &guifont
return?

> fine manual should I start looking for how to perform this necessary
> task in Linux?

See
:h 'guifont'
and
:h setting-guifont

regards,
Christian
--
Man ist dem andern, den man tadelt, ähnlicher und dem, den man lobt,
unähnlicher, als man glaubt.
                -- Jean Paul

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Teemu Likonen
In reply to this post by Dotan Cohen
* 2010-02-19 14:43 (+0200), Dotan Cohen wrote:

>> Unfortunately proportional fonts don't work that well in Vim but at
>> least changing font interactively is easy:
>>
>>    set guifont=*
>>
>> You can set a certain font by using font name instead of "*".

> Thanks. When I use names that I suspect (such as Tahoma, which is an
> installed font) nothing happens. How can I find a list of valid font
> names? I'm on Kubuntu 9.10. Thanks.

I suggest that you select a font from the dialog (set guifont=*) and
then check font's name with

    set guifont

command. You should see something like this in the bottom of the Vim
window:

    guifont=Tahoma 9

If you want to set that font from the Vim command line or put it in your
~/.vimrc file escape spaces with a backslash (\):

    set guifont=Tahoma\ 9

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
In reply to this post by Christian Brabandt
On 19 February 2010 15:05, Christian Brabandt <[hidden email]> wrote:
>> It gave  no error, but the font size did not change. Where in the vast
>
> Is that gvim? What does
> :echo &guifont
> return?
>

No, it was in Konsole. In GVIM things work better.


>> fine manual should I start looking for how to perform this necessary
>> task in Linux?
>
> See
> :h 'guifont'
> and
> :h setting-guifont
>

Thank you!


--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
In reply to this post by Teemu Likonen
> I suggest that you select a font from the dialog (set guifont=*) and
> then check font's name with
>
>    set guifont
>
> command. You should see something like this in the bottom of the Vim
> window:
>
>    guifont=Tahoma 9
>
> If you want to set that font from the Vim command line or put it in your
> ~/.vimrc file escape spaces with a backslash (\):
>
>    set guifont=Tahoma\ 9
>

Nice, thanks. I'm starting to get the hang of this.

One thing that is really holding me up is font sizes, as discussed
earlier. I suspect that I could put a line in the config file which
increases font size with "Ctrl =" and decreases with "Ctrl -", however
I cannot figure out what that line should be. Last question for today,
I promise!

Thanks!

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to change font on the fly?

John Beckett-2
Dotan Cohen wrote:
> One thing that is really holding me up is font sizes, as
> discussed earlier. I suspect that I could put a line in the
> config file which increases font size with "Ctrl =" and
> decreases with "Ctrl -", however I cannot figure out what
> that line should be. Last question for today, I promise!

I haven't tried it, but perhaps the info here will help:
http://vim.wikia.com/wiki/Change_font_size_quickly

It also has links to a couple of other similar things.

John

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Tony Mechelynck
In reply to this post by Dotan Cohen
On 19/02/10 14:49, Dotan Cohen wrote:

> On 19 February 2010 15:05, Christian Brabandt<[hidden email]>  wrote:
>>> It gave  no error, but the font size did not change. Where in the vast
>>
>> Is that gvim? What does
>> :echo&guifont
>> return?
>>
>
> No, it was in Konsole. In GVIM things work better.
>
>
[...]


In a terminal, Vim has absolutely no control over the font. In konsole
it's "Settings => Edit current profile => Appearance => Edit font",
which changes the font used by the present konsole session, in and out
of Vim.


Best regards,
Tony.
--
Christianity has not been tried and found wanting; it has been found
difficult and not tried.
                -- G. K. Chesterton

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

David Fishburn-2
In reply to this post by Dotan Cohen
> One thing that is really holding me up is font sizes, as discussed
> earlier. I suspect that I could put a line in the config file which
> increases font size with "Ctrl =" and decreases with "Ctrl -", however
> I cannot figure out what that line should be. Last question for today,
> I promise!

I created a tip for this.
On the vimtips website search for "firefox".

It was something like increase decrease fonts a la Firefox.

If you can't find it report back as I use this daily. Especially  
flipping between monitors with different resolutions.

--
David Fishburn


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
On 20 February 2010 14:54, David Fishburn <[hidden email]> wrote:

>> One thing that is really holding me up is font sizes, as discussed
>> earlier. I suspect that I could put a line in the config file which
>> increases font size with "Ctrl =" and decreases with "Ctrl -", however
>> I cannot figure out what that line should be. Last question for today,
>> I promise!
>
> I created a tip for this.
> On the vimtips website search for "firefox".
>
> It was something like increase decrease fonts a la Firefox.
>
> If you can't find it report back as I use this daily. Especially flipping
> between monitors with different resolutions.
>

‎Thanks, David, I found these two but neither are accredited to you:
http://vim.wikia.com/wiki/VimTip414
http://vim.wikia.com/wiki/VimTip760


--
Dotan Cohen

http://bido.com
http://what-is-what.com

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

panshizhu
In reply to this post by Dotan Cohen
Dotan Cohen 写道:
> Depending on what I am editing, I sometimes prefer a fixed-width font
> and other times a proportional font. My previous editor, Kate (KDE
> Advanced Text Editor) lets the user change the font on the fly. Can
> VIM do this, or is playing with the config file (thus requiring a
> restart) the only way?
>
> Thanks in advance!

If you're using konsole then your current editor is konsole, not vim. So
you should tell konsole how to change the font.

When you run vim inside konsole, it is possible to change font size of
konsole by some konsole-specific escape-codes which can be sent inside
vim script, you can check it in KDE forum. This is only available in
konsole, not with other terminal applications.

If you use gnu screen, this may not be much useful, since vim now run
inside gnu screen instead of konsole, and we had no control over konsole.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
> If you're using konsole then your current editor is konsole, not vim. So you
> should tell konsole how to change the font.
>
> When you run vim inside konsole, it is possible to change font size of
> konsole by some konsole-specific escape-codes which can be sent inside vim
> script, you can check it in KDE forum. This is only available in konsole,
> not with other terminal applications.
>
> If you use gnu screen, this may not be much useful, since vim now run inside
> gnu screen instead of konsole, and we had no control over konsole.
>

Thanks, I did not know how all that works. I use VIM in two situations:
1) In Konsole on my local machine, under screen.
2) Via SSH in Putty on Windows or a virtual terminal in Linux, also
under screen.

--
Dotan Cohen

http://bido.com
http://what-is-what.com

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

panshizhu
Dotan Cohen 写道:

>> If you're using konsole then your current editor is konsole, not vim. So you
>> should tell konsole how to change the font.
>>
>> When you run vim inside konsole, it is possible to change font size of
>> konsole by some konsole-specific escape-codes which can be sent inside vim
>> script, you can check it in KDE forum. This is only available in konsole,
>> not with other terminal applications.
>>
>> If you use gnu screen, this may not be much useful, since vim now run inside
>> gnu screen instead of konsole, and we had no control over konsole.
>>
>
> Thanks, I did not know how all that works. I use VIM in two situations:
> 1) In Konsole on my local machine, under screen.
> 2) Via SSH in Putty on Windows or a virtual terminal in Linux, also
> under screen.

In both case you cannot change font inside vim, since the environment of
vim is now screen and you cannot change the font in screen.

You can always change font directly in konsole or putty menu though.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

Dotan Cohen
> In both case you cannot change font inside vim, since the environment of vim
> is now screen and you cannot change the font in screen.
>

Really, because of screen? Thanks, I did not know that.

> You can always change font directly in konsole or putty menu though.
>

Yes.


--
Dotan Cohen

http://bido.com
http://what-is-what.com

Please CC me if you want to be sure that I read your message. I do not
read all list mail.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change font on the fly?

David Fishburn-2
In reply to this post by Dotan Cohen
On Sat, Feb 20, 2010 at 3:27 PM, Dotan Cohen <[hidden email]> wrote:

> On 20 February 2010 14:54, David Fishburn <[hidden email]> wrote:
>>> One thing that is really holding me up is font sizes, as discussed
>>> earlier. I suspect that I could put a line in the config file which
>>> increases font size with "Ctrl =" and decreases with "Ctrl -", however
>>> I cannot figure out what that line should be. Last question for today,
>>> I promise!
>>
>> I created a tip for this.
>> On the vimtips website search for "firefox".
>>
>> It was something like increase decrease fonts a la Firefox.
>>
>> If you can't find it report back as I use this daily. Especially flipping
>> between monitors with different resolutions.
>>
>
> ‎Thanks, David, I found these two but neither are accredited to you:
> http://vim.wikia.com/wiki/VimTip414
> http://vim.wikia.com/wiki/VimTip760
>


This was the thread I had started:
http://groups.google.com/group/vim_use/browse_thread/thread/ef7bc332e9599bf0/29053fefdd545991?lnk=gst&q=font+firefox+dfishburn#29053fefdd545991


This was the tip I created:
http://vim.wikia.com/wiki/Increase/decrease_fontsize_using_a_map_ala_firefox


Looks like someone cleaned up the tips and merged them.

Anyway, there you have it.

Dave

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Loading...