Many systems offer + and - zoom buttons. Can someone please demonstrate how such two buttons can be emulated with gvim?

This means that clicking the + button would increase the font size by one step. The - button does just the opposite.

  • 2
    Start with :h toolbar-icon and :h guifont – VanLaser Feb 14 '16 at 17:20
  • 4
    ... and combine with vim.wikia.com/wiki/Change_font_size_quickly (I'm lazy, ... I don't need it :D ) – VanLaser Feb 14 '16 at 17:41
  • Thanks! I tried, at least with the vim.wikia link. The defined commands seem to be ignored in my gvim, so I am still working on it. – Yossi Gil Feb 15 '16 at 9:25
  • I think the pattern definition has an extra space which will not work on Windows, or in OSes where guifont looks like FontName:h12 instead of FontName\ 12. And of course try without the has("gui_gtk2") check (at least for Windows). – VanLaser Feb 15 '16 at 10:26
  • Not sure what to make of this. I am an Ubuntu user. – Yossi Gil Feb 16 '16 at 19:29

I think something along the following lines should work:

amenu ToolBar.Builtin#31   :let &guifont=substitute(&guifont, '\(\d\+\)', '\=submatch(1)+1', '')<cr>
amenu ToolBar.Builtin#32   :let &guifont=substitute(&guifont, '\(\d\+\)', '\=submatch(1)-1', '')<cr>

Now, to include nice icons, you simply need to add the icon argument.

  • This did not work for me. I got the blurry icons, but clicking these makes the screen refresh without doing anything. I still have to change the font size manually. – Yossi Gil Feb 17 '16 at 11:34
  • Try :echo substitute(&guifont, '\(\d\+\)', '\=submatch(1)-1', '') what does that give you – Christian Brabandt Feb 17 '16 at 12:48
  • Nothing happens. Not sure there was even a refresh. – Yossi Gil Feb 17 '16 at 17:55
  • You should see an output. What is your guifont setting? – Christian Brabandt Feb 17 '16 at 19:24
  • 2
    that looks correct. And if you run this command: :let &guifont=substitute(&guifont, '\(\d\+\)', '\=submatch(1)-1', '') Does that decrease your font size? – Christian Brabandt Feb 17 '16 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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