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

Re: Firefox CTRL-+ for changing the guifont size map

Expand Messages
  • Hari Krishna Dara
    ... This is not a bug. For expressions to work, the replacement pattern should start with = . If you want to use = you have to use string constants (with
    Message 1 of 10 , Oct 1, 2007
    • 0 Attachment
      On Mon, 1 Oct 2007 at 6:44pm, David Fishburn wrote:

      >
      > On 10/1/07, David Fishburn <dfishburn.vim@...> wrote:
      >> My most used feature of FireFox is the ability to quickly and easily
      >> change the fontsize of the text I am reading.
      >>
      >> So you can hit CTRL+ and CTRL- repeatedly to get the text the size you want.
      >>
      >> I was trying to do the same with Vim 7.1 (on WinXP) using a substitute command.
      >>
      >> :echo &guifont
      >> Bitstream_Vera_Sans_Mono:h11:b:cANSI
      >>
      >> So I tried some variations of this substitue command:
      >> echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1\2\3', '')
      >> echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1\=submatch(2)\3', '')
      >> echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1'.submatch(2).'\3', '')
      >>
      >> With the end goal of doing this and hoping I could do arithmetic in
      >> the submatch without it ending up as string concatentation:
      >> echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1'.
      >> (submatch(2)+1) .'\3', '')
      >>
      >> Anyway, I can't get any of these to work and I was wondering if
      >> someone might have some suggestions. The submatches always end up as
      >> "submatch" literals added instead of the contents of the match.
      >>
      >> So final result would be something like this:
      >> :nnoremap + :let &guifont=substitute(&guifont,
      >> '\(.*:h\)\(\d\+\)\(.*\)', '\1'. (submatch(2)+1) .'\3', '')
      >> :nnoremap - :let &guifont=substitute(&guifont,
      >> '\(.*:h\)\(\d\+\)\(.*\)', '\1'. (submatch(2)-1) .'\3', '')
      >
      > Little more progress on this, looks like I am running into a Vim bug.
      >
      > This works:
      > echo substitute(&guifont, '\%(.*:h\)\(\d\+\)\%(.*\)', '\=submatch(0)', '')
      > Meaning I get this back:
      > Bitstream_Vera_Sans_Mono:h11:b:cANSI
      >
      > This does NOT work:
      > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\%(.*\)', '\1\=submatch(1)', '')
      > The result is:
      > Bitstream_Vera_Sans_Mono:h=submatch(1)

      This is not a bug. For expressions to work, the replacement pattern
      should start with "\=". If you want to use "\=" you have to use string
      constants (with "." to append them) and submatch()s to assemble your
      replacement string.

      --
      HTH,
      Hari

      >
      > Or:
      > This does NOT work:
      > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\%(.*\)',
      > '\1'.'\=submatch(1)', '')
      > The result is:
      > Bitstream_Vera_Sans_Mono:h=submatch(1)
      >
      > :version
      > :version
      > VIM - Vi IMproved 7.1 (2007 May 12, compiled Aug 8 2007 16:27:15)
      > MS-Windows 32 bit GUI version with OLE support
      > Included patches: 1-56
      > Compiled by fishburn@FISHBURN-M20
      > Big version with GUI. Features included (+) or not (-):
      > +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset
      > +cindent +clientserver +clipboard +cmdline_compl
      > +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape
      > +dialog_con_gui +diff +digraphs -dnd -ebcdic +emacs_tags
      > +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
      > +folding -footer +gettext/dyn -hangul_input +iconv/dyn
      > +insert_expand +jumplist +keymap +langmap +libcall +linebreak
      > +lispindent +listcmds +localmap +menu +mksession
      > +modify_fname +mouse +mouseshape +multi_byte +multi_lang -mzscheme
      > +netbeans_intg +ole -osfiletype +path_extra +perl/dyn
      > -postscript +printer -profile +python/dyn +quickfix +reltime
      > +rightleft -ruby +scrollbind +signs +smartindent -sniff
      > +statusline -sun_workshop +syntax +tag_binary +tag_old_static
      > -tag_any_white -tcl -tgetent -termresponse +textobjects
      > +title +toolbar +user_commands +vertsplit +virtualedit +visual
      > +visualextra +viminfo +vreplace +wildignore +wildmenu
      > +windows +writebackup -xfontset -xim -xterm_save +xpm_w32
      >
      > >
      >

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • A.Politz
      ... A substitution is either an expression which starts with = , or it is a string, which can contain special sub-replace patterns like 1 . You can t mix
      Message 2 of 10 , Oct 1, 2007
      • 0 Attachment
        David Fishburn wrote:

        >Little more progress on this, looks like I am running into a Vim bug.
        >
        >This works:
        > echo substitute(&guifont, '\%(.*:h\)\(\d\+\)\%(.*\)', '\=submatch(0)', '')
        >Meaning I get this back:
        > Bitstream_Vera_Sans_Mono:h11:b:cANSI
        >
        >This does NOT work:
        > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\%(.*\)', '\1\=submatch(1)', '')
        >The result is:
        > Bitstream_Vera_Sans_Mono:h=submatch(1)
        >
        >Or:
        >This does NOT work:
        > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\%(.*\)',
        >'\1'.'\=submatch(1)', '')
        >The result is:
        > Bitstream_Vera_Sans_Mono:h=submatch(1)
        >
        >
        A substitution is either an expression which starts with '\=', or it is
        a string,
        which can contain special sub-replace patterns like '\1'.
        You can't mix it.

        -ap

        --
        Ich hab geträumt, der Krieg wär vorbei.


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • David Fishburn
        ... Ahh, thank you Hari. That makes sense. So I have this working this way (thanks to your suggestion): nnoremap :silent! let &guifont =
        Message 3 of 10 , Oct 1, 2007
        • 0 Attachment
          On 10/1/07, Hari Krishna Dara <hari.vim@...> wrote:
          >
          >
          > On Mon, 1 Oct 2007 at 6:44pm, David Fishburn wrote:
          >
          > >
          > > On 10/1/07, David Fishburn <dfishburn.vim@...> wrote:

          ...

          > > Little more progress on this, looks like I am running into a Vim bug.
          > >
          > > This works:
          > > echo substitute(&guifont, '\%(.*:h\)\(\d\+\)\%(.*\)', '\=submatch(0)', '')
          > > Meaning I get this back:
          > > Bitstream_Vera_Sans_Mono:h11:b:cANSI
          > >
          > > This does NOT work:
          > > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\%(.*\)', '\1\=submatch(1)', '')
          > > The result is:
          > > Bitstream_Vera_Sans_Mono:h=submatch(1)
          >
          > This is not a bug. For expressions to work, the replacement pattern
          > should start with "\=". If you want to use "\=" you have to use string
          > constants (with "." to append them) and submatch()s to assemble your
          > replacement string.


          Ahh, thank you Hari. That makes sense.

          So I have this working this way (thanks to your suggestion):
          nnoremap <C-Up> :silent! let &guifont = substitute(&guifont,
          '\(.*:h\)\(\d\+\)\(.*\)',
          '\=submatch(1).eval(submatch(2)+1).submatch(3)', '')<CR>
          nnoremap <C-Down> :silent! let &guifont = substitute(&guifont,
          '\(.*:h\)\(\d\+\)\(.*\)',
          '\=submatch(1).eval(submatch(2)-1).submatch(3)', '')<CR>


          But then realized, it is a bit redundant and reduced it to the final
          working version:
          nnoremap <C-Up> :silent! let &guifont = substitute(&guifont, '\d\+',
          '\=eval(submatch(0)+1)', '')<CR>
          nnoremap <C-Down> :silent! let &guifont = substitute(&guifont, '\d\+',
          '\=eval(submatch(0)-1)', '')<CR>

          I will add this as a new Vim Tip, once I figure out how to use the new
          system with login's and all.

          Thanks for the help.
          Dave

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • David Fishburn
          ... http://vim.wikia.com/wiki/Increase/decrease_fontsize_using_a_map_ala_FireFox My only issue with it currently is the dreaded Hit ENTER or type command to
          Message 4 of 10 , Oct 1, 2007
          • 0 Attachment
            > I will add this as a new Vim Tip, once I figure out how to use the new
            > system with login's and all.

            http://vim.wikia.com/wiki/Increase/decrease_fontsize_using_a_map_ala_FireFox

            My only issue with it currently is the dreaded "Hit ENTER or type
            command to continue" in some cases. The font has to get _pretty_ big
            or _very_ small to trigger it, but it is there.

            I tried adding let saved_more = &more \| set nomore ... \| let &more =
            saved_more around it but that just made the command longer which
            trigger the prompt sooner. I could put it in a function, but that
            seems overkill.

            Enjoy.
            Dave

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • John Beckett
            ... Good work. Here are a couple of comments on the wikitext (the text you typed in). ... However, the leading : causes an indent (and :: would give more
            Message 5 of 10 , Oct 1, 2007
            • 0 Attachment
              David Fishburn wrote:
              >> I will add this as a new Vim Tip, once I figure out how to
              >> use the new system with login's and all.
              >
              > http://vim.wikia.com/wiki/Increase/decrease_fontsize_using_a_m
              > ap_ala_FireFox

              Good work. Here are a couple of comments on the wikitext (the text you typed
              in).

              You have the line:
              :echo &guifont

              However, the leading ':' causes an indent (and '::' would give more indent).

              The simplest fix is to insert a space before the ':'. A leading space causes
              the line to be treated as if it were in <pre>...</pre> tags.

              You used multiple spaces to align some text. That won't work unless in a
              <pre> block. I would not bother trying to align (it is possible to enter
              some magic to get a table, but the effort is often not worthwhile).

              However, you might like to add '<br>' to lines where you want to force a
              line break. In html, you might put <br />, but just <br> is fine in
              wikitext. For example, you might want:

              Indicates:<br>

              If you edit the tip, please put a short comment in the Summary box
              ("Improved formatting"), and use the 'Show preview' button to check before
              saving.

              John


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • key.vim@googlemail.com
              Hi, thanks for the nice macros to increase and decrease the font-size. I use them, but encounter the following problem: I use 7.1.132 on ubuntu with a gnome
              Message 6 of 10 , Oct 3, 2007
              • 0 Attachment
                Hi,

                thanks for the nice macros to increase and decrease the font-size.
                I use them, but encounter the following problem:

                I use 7.1.132 on ubuntu with a gnome desktop and devilspie to
                place and resize my applications as i wish. gvim is
                automatically made fullscreen with no decoration
                (menubar, windowtitle, etc). when i now resize the
                font obviously there is a mismatch in the current
                gvim-window-size. if i reduce the font size, the right
                hand side, and the lower part of the vim window are
                gray. if i increase the fontsize, i will not be able to read
                the status or command line.

                Is there an automatic way to "redraw" gvim to match the
                current window size?

                cheers,
                Keyan


                On Oct 1, 10:48 pm, "David Fishburn" <dfishburn....@...> wrote:
                > My most used feature ofFireFoxis the ability to quickly and easily
                > change the fontsize of the text I am reading.
                >
                > So you can hit CTRL+ and CTRL- repeatedly to get the text the size you want.
                >
                > I was trying to do the same with Vim 7.1 (on WinXP) using a substitute command.
                >
                > :echo &guifont
                > Bitstream_Vera_Sans_Mono:h11:b:cANSI
                >
                > So I tried some variations of this substitue command:
                > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1\2\3', '')
                > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1\=submatch(2)\3', '')
                > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1'.submatch(2).'\3', '')
                >
                > With the end goal of doing this and hoping I could do arithmetic in
                > the submatch without it ending up as string concatentation:
                > echo substitute(&guifont, '\(.*:h\)\(\d\+\)\(.*\)', '\1'.
                > (submatch(2)+1) .'\3', '')
                >
                > Anyway, I can't get any of these to work and I was wondering if
                > someone might have some suggestions. The submatches always end up as
                > "submatch" literals added instead of the contents of the match.
                >
                > So final result would be something like this:
                > :nnoremap + :let &guifont=substitute(&guifont,
                > '\(.*:h\)\(\d\+\)\(.*\)', '\1'. (submatch(2)+1) .'\3', '')
                > :nnoremap - :let &guifont=substitute(&guifont,
                > '\(.*:h\)\(\d\+\)\(.*\)', '\1'. (submatch(2)-1) .'\3', '')
                >
                > TIA,
                > Dave


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Tony Mechelynck
                ... Instead of making gvim fullscreen by means of some external application Vim knows nothing about, do it by Vim means, just after setting the guifont : a)
                Message 7 of 10 , Oct 3, 2007
                • 0 Attachment
                  key.vim@... wrote:
                  > Hi,
                  >
                  > thanks for the nice macros to increase and decrease the font-size.
                  > I use them, but encounter the following problem:
                  >
                  > I use 7.1.132 on ubuntu with a gnome desktop and devilspie to
                  > place and resize my applications as i wish. gvim is
                  > automatically made fullscreen with no decoration
                  > (menubar, windowtitle, etc). when i now resize the
                  > font obviously there is a mismatch in the current
                  > gvim-window-size. if i reduce the font size, the right
                  > hand side, and the lower part of the vim window are
                  > gray. if i increase the fontsize, i will not be able to read
                  > the status or command line.
                  >
                  > Is there an automatic way to "redraw" gvim to match the
                  > current window size?
                  >
                  > cheers,
                  > Keyan

                  Instead of making gvim fullscreen by means of some external application Vim
                  knows nothing about, do it by Vim means, just after setting the 'guifont':

                  a) in the vimrc:

                  if has('gui_running')
                  " detect which 'guifont' format is required by the current gvim
                  if has('gui_gtk2')
                  set gfn=Courier\ New\ 9
                  elseif has('gui_photon')
                  set gfn=Courier\ New:s9
                  elseif has('gui_kde')
                  set gfn=Courier\ New/9/-1/5/50/0/0/0/1/0
                  elseif has('x11')
                  set gfn=*-courier-medium-r-normal-*-*-90-*-*-m-*-*
                  else
                  set gfn=Courier_New:h9:cDEFAULT
                  endif
                  " make sure the gvim window starts at top left
                  if exists(':winpos') == 2
                  winpos 0 0
                  endif
                  " maximize the gvim window
                  set lines=99999 columns=99999
                  endif

                  b) Doing it manually (e.g. for GTK2):

                  :set gfn=Andale\ Mono\ 8 lines=99999 columns=99999

                  Note: When changing the 'guifont' manually, you should already know (or find
                  out) which of the 5 possible mutually incompatible formats your version requires.

                  c) when changing the font in a user command or function:

                  if has('gui_running')
                  call FontResize()
                  set lines=99999 columns=99999
                  endif


                  Best regards,
                  Tony.
                  --
                  Cynic, n.:
                  A blackguard whose faulty vision sees things as they are, not
                  as they ought to be. Hence the custom among the Scythians of plucking
                  out a cynic's eyes to improve his vision.
                  -- Ambrose Bierce, "The Devil's Dictionary"

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Zbikow
                  This might not work as it did not for me. After invoking font selection window by set guifont=* i saw that that by default i m using a font (fixedsys) which
                  Message 8 of 10 , Oct 4, 2007
                  • 0 Attachment
                    This might not work as it did not for me. After invoking font
                    selection window by "set guifont=*" i saw that that by default i'm
                    using a font (fixedsys) which is not scalable (the size list contains
                    only one size). After changing the fonts to scalable everything works.

                    HTH others if they have the same problem

                    regards
                    Zbikow


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.