vimdows


Ⅰ. 插件描述

Vim plugin that makes GUI experience better under Windows

Ⅱ. 基本信息

创建日期:  2017-05-25
使用用户:  1
Github星:  8
插件作者:  Grzegorz Kozub

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'grzegorzkozub/vimdows'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'grzegorzkozub/vimdows'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'grzegorzkozub/vimdows'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/grzegorzkozub/vimdows

Ⅳ. 文档说明

# What is it

Vim plugin that makes GUI experience better under Windows:

  • automates maximizing and restoring the window
  • provides full screen functionality
  • fixes the lower-right window border when maximized
  • remembers the window position and size

How to install

Plugin installation

Use your favorite plugin manager. I prefer vim-plug:

Plug 'GrzegorzKozub/vimdows'

Required vimrc changes

This plugin uses g:VIMDOWS_SCREEN variable stored in viminfo to save and restore the window position and size. This depends on the following lines added somewhere to the top of your vimrc. The first one enables GVim to store all-caps global variables in viminfo and the other one reads it early:

let &viminfo = &viminfo . ',!'
try | rviminfo | catch | endtry

If you don't like this, set g:vimdows_screen_memento to 0 to disable this functionality.

How to use

The plugin provides functions that aim to make GVim experience under Windows nicer. By default, some of them are mapped to keys and some run in a response to GVim events.

vimdows#get_screen

This is the only function in this plugin that is compatible with Neovim.

It returns a JSON object that describes the current screen resolution and scaling: { 'width': 3200, 'height': 1800, 'dpi': 240 }. Example use:

if has('win32') && has('gui_running')
  set guifont=Fira\ Code\ Retina:h12
  let s:screen = eval(vimscreen#get_screen())
  if s:screen.height == 1800 && s:screen.dpi == 240
    set columns=127 lines=31
    winpos 60 62
  endif
endif

If this function gives you incorrect results, open your gvim.exe properties, on the Compatibility tab press Change high DPI settings button, check Override high DPI scaling behavior checkbox and select Application in the corresponding dropdown. Or just import this Registry script:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files\\Neovim\\bin\\nvim-qt.exe"="~ HIGHDPIAWARE"

vimdows#get_maximized and vimdows#get_full_screen

Return 1 if GVim is, respectively, maximized or in full screen and 0 otherwise.

vimdows#maximize and vimdows#restore

The former maximizes GVim window and the latter restores it.

vimdows#enter_full_screen and vimdows#exit_full_screen

Full screen mode hides title bar, menu, toolbar and taskbar.

vimdows#maximized_toggle and vimdows#full_screen_toggle

These are the toggle variants of the above functions. F10 will toggle maximized and F11 will toggle full screen. If you don't like these mappings, disable them in your vimrc:

let g:vimdows_mappings = 0

vimdows#fix_background

When GVim is maximized or in full screen there's a bright frame on the right side and on the bottom side of the text area that does not match current GVim theme. To correct this you can use vimdows#fix_background.

This function is called every time GVim gets maximized or enters full screen and also when changing themes when maximized or in full screen. You can opt-out in your vimrc by:

let g:vimdows_background_fixes = 0

Then you will be able to use this function yourself.

vimdows#save_screen and vimdows#restore_screen(allowFullScreen)

In order to work, this requires the vimrc changes described above. The following GVim window parameters are saved: position, size, is it maximized, is it full screen. The allowFullScreen parameter can be used to force GVim to go out of full screen on next launch.

Your window will be saved when you exit GVim and restored when you launch GVim next time. You can disable this in your vimrc like so:

let g:vimdows_screen_memento = 0

References

Lots of inspiration and some code taken from:

添加新评论