Loading ...
Sorry, an error occurred while loading the content.

Set gfn based on screen resolution

Expand Messages
  • philipx
    Is there a way to determine the screen resolution in gVim and act upon that information, for example to set a different font size? I seem to find myself
    Message 1 of 3 , Oct 1, 2011
    • 0 Attachment
      Is there a way to determine the screen resolution in gVim and act upon
      that information, for example to set a different font size?

      I seem to find myself working in two different modes: either on my
      laptop or on a large screen. Maybe I'm getting old, or maybe the
      distance to the screen is different between the two (I suspect I sit
      closer to the laptop's screen), but I use Menlo:h11 on my laptop and
      I'd like :h12 or even :h13 when I'm connected to the monitor.

      Thank you!

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Tony Mechelynck
      ... I don t think you can ask Vim for the pixel size of your screen, but you can do almost as good (after gvim startup, i.e. either in the gvimrc or in a
      Message 2 of 3 , Oct 1, 2011
      • 0 Attachment
        On 01/10/11 10:15, philipx wrote:
        > Is there a way to determine the screen resolution in gVim and act upon
        > that information, for example to set a different font size?
        >
        > I seem to find myself working in two different modes: either on my
        > laptop or on a large screen. Maybe I'm getting old, or maybe the
        > distance to the screen is different between the two (I suspect I sit
        > closer to the laptop's screen), but I use Menlo:h11 on my laptop and
        > I'd like :h12 or even :h13 when I'm connected to the monitor.
        >
        > Thank you!
        >

        I don't think you can ask Vim for the pixel size of your screen, but you
        can do almost as good (after gvim startup, i.e. either in the gvimrc or
        in a GUIEnter autocommand):

        1. Set some standard 'guifont'
        2. :set lines=999 columns=9999
        (gvim will now set its screen size to within one character cell of your
        monitor size, and adjust the option values accordingly)
        3. Compare &lines and/or &columns with some reference values and
        increase the 'guifont' size if larger.

        Note: There are several incompatible platform-dependent 'guifont'
        formats, and each gvim version recognizes only one of them. If someday
        you find yourself on Linux and try to set the 'guifont' you set on
        Windows, it may or may not give you an error but it will almost
        certainly not set the font you expected. See
        http://vim.wikia.com/wiki/Setting_the_font_in_the_GUI

        Here are a few examples:
        GTK2:
        :set gfn=Courier\ New\ 11
        kvim (obsolete):
        :set gfn=Courier\ New/11/-1/5/50/0/0/0/1/0
        Photon:
        :set gfn=Courier\ New:s11
        other X11 (including the now obsolete GTK1):
        :set gfn=-*-courier-medium-r-normal-*-*-110-*-*-m-*-*
        Mac:
        :set gfn=Monaco:h11
        Windows:
        :set gfn=Courier_New:h11:cDEFAULT


        Best regards,
        Tony.
        --
        You have the body of a 19 year old. Please return it before it gets
        wrinkled.

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Dennis Benzinger
        Hi! ... You could use system() to execute a program to query the resolution. For example xdpyinfo or xwininfo -root if you are running under an X server.
        Message 3 of 3 , Oct 1, 2011
        • 0 Attachment
          Hi!

          Am 01.10.2011 10:15, schrieb philipx:
          > Is there a way to determine the screen resolution in gVim and act upon
          > that information, for example to set a different font size?
          > [...]

          You could use system() to execute a program to query the resolution. For
          example "xdpyinfo" or "xwininfo -root" if you are running under an X server.


          HTH,
          Dennis Benzinger

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.