1

I used to use gvimfullscreen.dll to toggle a full screen window state on gvim for Windows. It made gvim full screen, not maximised, with no titlebar.

I have not used gvim on Windows for some time until recently and it's no longer working for me. The many mentions of this file I have found on the internet are old and there are no discussions about it no longer working. I am using gvim for Windows 9.0 and I probably last used it successfully with v8.0.

I get this error:

Error detected while processing function ToggleFullScreen:

line 4:

E364: Library call failed for "ToggleFullScreen()"

https://www.vim.org/scripts/script.php?script_id=2596

" Fullscreen with Alt-Enter
function! ToggleFullScreen()
  if has('gui_gtk2')
    :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")
  elseif has('gui_win32')
    :call libcallnr(expand("$VIM") . "/win/gvimfullscreen.dll", "ToggleFullScreen", 0)
  endif
endfunction
set <M-CR>=\<ESC>\<CR>
map <silent> <M-CR> :call ToggleFullScreen()<CR>
5
  • Are you using a Win32 or an amd64 version of gVim? I suspect that the binary distribution is compiled for Win32. You can figure out using the :version command Sep 27, 2022 at 3:32
  • @VivianDeSmedt I am using the 64-bit version of gvim and I actually was using the 64-bit dll as well, but I renamed as I thought it would be less hassle than editing my config.
    – paradroid
    Sep 27, 2022 at 6:00
  • Good :-) Maybe the problem is that the $VIM variable is not pointing to the correct folder or that the DLL is not placed correctly. Did my answer solved your problem? Sep 27, 2022 at 6:06
  • There is also a similar plugin: github.com/imranZERO/wintweak.gvim Sep 27, 2022 at 6:17
  • @ChristianBrabandt Thanks. I'll check that out if I can't get this working. I have already tried another one that works, but it's a bit too aggressive as you cannot alt-tab any other windows over it when it full screen. github.com/xolox/vim-shell
    – paradroid
    Sep 27, 2022 at 6:43

2 Answers 2

1

If you are using a 64-bit version of Vim you have to adapt the call to use the 64 bit version of the dll:

" Fullscreen with Alt-Enter
function! ToggleFullScreen()
  if has('gui_gtk2')
    :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")
  elseif has('gui_win32')
    :call libcallnr(expand("$VIM") . "/win/gvimfullscreen_64.dll", "ToggleFullScreen", 0)
  endif
endfunction
set <M-CR>=\<ESC>\<CR>
map <silent> <M-CR> :call ToggleFullScreen()<CR>

The gvimfullscreen_64.dll is available at: gvimfullscreen_64.dll

The code suppose the dll is placed in a win folder next to the vim90 folder.

" Fullscreen with Alt-Enter
function! ToggleFullScreen()
  if has('gui_gtk2')
    :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")
  elseif has('gui_win32')
    :call libcallnr(expand("$VIM") . "/vim90/win/gvimfullscreen_64.dll", "ToggleFullScreen", 0)
  endif
endfunction
set <M-CR>=\<ESC>\<CR>
map <silent> <M-CR> :call ToggleFullScreen()<CR>

If the win folder is a subfolder of the vim90 folder the code must be adapted as follow:

You can determine if you are using a 32 bit or a 64 bit version of Vim by looking at the second line of the result of the :version Vim command

VIM - vi Improved 9.0 ...
MS-Windows 64-bit GUI/Console version ...
...

vs.

VIM - vi Improved 9.0 ...
MS-Windows 32-bit GUI/Console version ...
...
20
  • Thanks, but I edited the config twice, using both versions of your changes and I used the .dll file from your link and I still get the same error. I used the line :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) as my $VIM is set to $HOME\vimfiles on Windows. The file in the same directory as gvim.exe.
    – paradroid
    Sep 27, 2022 at 6:07
  • Have you tested it yourself? Does it work with gvim 9.0?
    – paradroid
    Sep 27, 2022 at 6:08
  • It works for me, I have tested it. If your $VIM points to $HOME\vimfiles the gvimfullscreen.dll should be in $HOME\vimfiles\win (if you are using the first version of the code). Sep 27, 2022 at 6:10
  • 1
    I added my solution. Cheers.
    – paradroid
    Oct 5, 2022 at 7:16
  • 1
    @paradroid Not sure if I'm reading the above right, but in this message you said that you used the command libcallnr(expand("$VIM") . "/vim90/gvimfullscreen_64.dll" (without /win/) but as far as I can tell from your other comments the file is actually in the win subfolder. Could you confirm if you've tried the command without editing the paths?
    – Rich
    Oct 5, 2022 at 9:14
1

I could not get gvimfullscreen.dll working and searching the web showed that quite a few people have had this problem but there was no solution.

EDIT: This comment solves the problem, as I had forgotten that I had defined $VIM to another location.

I ended up using this plugin: https://github.com/kkoenig/wimproved.vim, but I found it had the same problem as gvimfullscreen.dll in that it did not return to the previous screen size when the window is restored. I then found this vimscript which saves and restores the screen size:

https://vim.fandom.com/wiki/Restore_screen_size_and_position

So in my gvimrc I source that script and use some logic to use the plugin and restore the screen size using the functions from the script.

" Restore window positions
source $VIM/vimrc.d/restore_position.vim

" Fullscreen toggle with F11
function! ToggleFullScreen()
  if has('gui_gtk2')
    call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")
  elseif has('gui_win32')
    if !exists("s:fullscr")
      let s:fullscr = 0
    endif
    if (s:fullscr == 0)
      call ScreenSave()
      WToggleFullscreen
      let s:fullscr = 1
    elseif (s:fullscr == 1)
      WToggleFullscreen
      call ScreenRestore()
      let s:fullscr = 0
    endif
  endif
endfunction
map <silent> <F11> :call ToggleFullScreen()<CR>

Everything works great now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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