Giter Site home page Giter Site logo

resize-font.gvim's Introduction

resize-font.gvim

Resizing gvim

(for Linux and Windows)

This plugin for gvim adds the ability to change font size (and therefore window size too) using the same methods used in most web browsers, terminal emulators and some other graphical text editors.

I may add Mac support if this plugin attracts any interest.

Usage

Mapping Action
Ctrl + = Increases text size
Ctrl + - Decreases text size
Ctrl + 0 Resets text to original size
Ctrl + mousewheel Resize text

In terminal vim or neovim the plugin exits and doesn't do anything.

Install

Plugin manager

Installation can be done via a plugin manager.

For vim-plug it's:

Plug 'eggbean/resize-font.gvim'

No plugin manager

If you don't use a plugin manager you can just place the script in...

~/.vim/plugin on Linux, or...

%USERPROFILE%\vimfiles\plugin on Windows.

Not working with your font?

This should work with all modern Unicode fonts, but if you find one which doesn't work tell me and I'll modify the regex. This is only likely to occur with Windows.

resize-font.gvim's People

Contributors

eggbean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kennypete passw

resize-font.gvim's Issues

Handling things where gvim versions do not work with plugin "v1" and improvements

I like this, though there are some things that I think need hardening/fixing and some that will enhance it (most of which I have done, except part of point 5 and all of point 7). I have it ready for a PR, but did not want to send it unannounced with so many changes - here is my updated forked version.

  1. Before v9.0 patch 1112 <C-_> will not work on Windows - refer patch 9.0.1112: test_mswin_event() can hang. A solution is to default map <C-=>= for the "FontSizeMinus" function when using a Windows version before that. It is a little clunky, but does the job.
  2. In Windows, the <C-Scroll*> mappings will not work before v8.2 patch 5069, though they do no harm. Refer
    patch 8.2.5069: various warnings from clang on MS-Windows.
  3. In Neovim, has("GUI_running") returns 1 (at least in the version I use just for testing; I don't use Neovim other than for that). So, it's probably best to include a specific test for Neovim, i.e., has('neovim'), though it's only needed in the vimscript version because the new (see the point following) vim9script version's test will exclude it anyway. (NB: Neovim returns 801 for v:version.)
  4. Since it is only relevant to the Vim GUI, it will only ever be a Vim plugin (so, never Neovim). In that context, and with the majority of Vim users probably using version 9, using vim9script makes sense. So, that's what I've done. The simplest way to have both scripts running in parallel (for the few people who may use different GUI versions, including some older ones) is to have both change_font_size_vim9script.vim and change_font_size.vim test for version 8.2 with/without patch 4807. (Note that vim9script works before v9.0, not just where has('vim9script'), so a good cut-off point, I think, is patch 8.2.4807: processing key eveints in Win32 GUI is not ideal, because that patch fixed <C-{whatever}>. (Before that patch, <C-{whatever}> mappings do nothing).
  5. Use maparg to ensure users' existing mappings are not overwritten and use map <silent> <Plug> too. The problem for the vimscript version, however, is that <C-{whatever}> does not work in version 8.2 before patch 4807 (in Windows at least, as noted). I did some testing using <F10> to <F12>, but it seems pretty flaky in Windows, and I don't want to burn more time testing it. (Using this Win64 zip version), amongst others in determining the points above in relation to version capability.)
  6. Using has('gui_gtk') covers both 2 and 3, so is a simple refinement.
  7. Although it's not wrong to recommend putting the script(s) directly into the .vim/plugin or vimfiles\plugin directory, it would be better recommending using the packages approach (outlined at :h packages). That is, using .vim/pack/{whatever}/start (or .vim/pack/{whatever}/opt, and calling it from your .gvimrc, which is probably preferable in this instance too, especially if you use console and GUI. That's because it would mean you then only source the script(s) when using the GUI rather than relying on the test in the script itself to finish when using console Vim). I've not updated the README.md in relation to this, but you could consider it - check out this README of mine if you like.
  8. Incidental: I popped in a GIF of it working in Debian WSL. You may want to look at your GIF - it is huge, comparatively.

That's about it. It's your repository so, if you're okay with what I have done, and are happy for a PR, let me know (and I'll make it and you can consider the few loose ends like point 5 after that).

I love the concept, btw, having stuffed around changing font sizes in the past, so thanks for putting it out there. (I will be taking the vim9script into my .gvimrc and _gvimrc directly because I prefer to have fewer plugins, and this is a pretty short script so only a small addition really.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.