1. Rui
  2. vim-qt
  3. Issues
Issue #50 open

Fullscreen mode like that of MacVim

H W Tovetjärn
created an issue

MacVim has a fullscreen mode with a select few options that (amongst other things) lets the background fill up the entire screen yet the viewport be of a fixed size (lines and columns) and centered. Essentially it makes it look like this: http://www.hogbaysoftware.com/static/writeroom/mac_os_screen_thumb.jpg

So even if used on a widescreen display the 80~ columns are in the middle instead of at the left side if the screen.

If this could be added it would be much appreciated.

Comments (17)

  1. Rui repo owner


    It is kind of sad that no other Vim GUI picked up on that option, it is a nice feature specially if you like things like Writeroom.

    I have started working on this in db472d4509bb, but so far I have only added the :set fullscreen command, but there are still some bugs to be fixed there. What is really missing is the :set fuopts that sets the behaviour of the window.

    TODO list

    • Find some time to do this :D
    • Find and kill remaining issues with :set fu
    • Add support for :set fuopts compatible with MacVIM
  2. abudden

    For what it's worth (in case anyone finds this page when searching or whatever), it is sort-of possible in Windows Vim (albeit in a nasty way). However, it would be really nice to have cross-platform built-in support.

    if has("win32")
    	let s:InFullScreenMode = 0
    	function! GoFullScreen()
    		if s:InFullScreenMode == 1
    		let s:SavedGuiOpts = &go
    		let s:SavedStal = &stal
    		set go& go-=m go-=T go-=r stal&
    		call libcallnr("vimtweak.dll", "EnableMaximize", 1)
    		call libcallnr("vimtweak.dll", "EnableCaption", 0)
    		let s:InFullScreenMode = 1
    	function! EndFullScreen()
    		if s:InFullScreenMode != 1
    		call libcallnr("vimtweak.dll", "EnableMaximize", 0)
    		call libcallnr("vimtweak.dll", "EnableCaption", 1)
    		exe "set go=" . s:SavedGuiOpts
    		exe "set stal=" . s:SavedStal
    		let s:InFullScreenMode = 0
    	command! GoFullScreen call GoFullScreen()
    	command! EndFullScreen call EndFullScreen()
  3. Rui repo owner

    Some work on this started on the tb-fullscreen branch. What we have so far:

    • :set fu enables fullscreen mode, but you can also your window manager to do it
    • There is now a :set fuoptions but currently it does nothing
    • When the window is in fullscreen mode, :set lines/columns will now resized the Vim canvas

    i.e. to get fullscreen with just 80 columns

    :set fu
    :set columns=80

    Things we don't do yet:

    • Background color: the margins around the canvas inherit the system style background color
    • maxvert,maxhorz: MacVim does things differently(?) they can specify they want the canvas to fiil all space while we assume that by default, but I don't know which value they assume for lines/cols if one is not specified.
  4. Rui repo owner

    Sigh, finally we are making some progress on this:

    • The vimshell widget should now be aligned (top center) at the center of the window - when in fullscreen mode

    Some pending questions that must be addressed:

    • What should be the background color around the vim shell? I've made it the same as Vim's background but it does not feel right.
    • We still don't have an option to maximize the widget like MacVim ":set fuopt maxvert,maxhoriz" - but set columns=9999 works in fullscreen too
    • MacVim has some goodies in fullscreen mode, e.g. the toolbar only shows up when we move the mouse to the top of the screen - do we want that too ?

    My own version of the script you added earlier, but using the latest version of vim-Qt in tb-fullscreen

    " Experimental fullscreen for vim-Qt
    let s:InFullScreenMode = 0
    function ToggleFullscreen()
        if s:InFullScreenMode == 1
    		      exe "set nofu"
    		      exe "set go=" . s:SavedGuiOpts
    		      exe "set stal=" . s:SavedStal
    		      let s:InFullScreenMode = 0
    		      let s:SavedGuiOpts = &go
    		      let s:SavedStal = &stal
            set go& go-=m go-=T go-=r stal&
    		      exe "set fu"
    		      exe "set columns=100"
    		      let s:InFullScreenMode = 1
    command! ToggleFullscreen call ToggleFullscreen()
    endif " Fullscreen vim-Qt

    do notice, that I hardcoded "set columns=100" in there :D

  5. H W Tovetjärn reporter

    Thank you for putting so much effort into this, it's really cool.

    Question! What desktop environment or window manager will this work in, or which ones can be (reasonably) supported? MacVim has it easy since OS X only has one window manager (to my knowledge) but GNU/Linux has an abundance! I use XMonad myself and have been looking for a way to setup a fullscreen mode, like this, in the window manager itself by tweaking the layouts. No success so far though.

    As for the background colour - I use the same in and around MacVim, it feels "right" to me.

    I'm not sure about the goodies, I'd rather have a reliable fullscreen that I enter and exit with a keybinding. Mostly I just shrug at eye candy...

  6. Rui repo owner

    In general all X11 windowmanagers that support the _NET_WM_STATE_FULLSCREEN X11 atom, but you really are dependant on the window manager. I'm currently using a tilling window manager (i3), and fullscreen mode works as intended, but I really have no idea about Xmonad.

    Usually there are two ways to enable fullscreen mode for a window

    1. The application marks the window as fullscreen and the window manager resizes the window and hides the toolbars.
    2. The window manager puts the window into fullscreen mode (triggered by some global keys), and sets the X11 atom.

    Both ways should work here, i.e. it does not matter if you do ":set fu" or if it is the window manager that puts the window into fullscreen.

  7. Rui repo owner

    Weird graphicall glitch (using the script above), seems that the menubar becomes visible immediatly before the windows goes into full screen.

  8. Rui repo owner

    Seeing some weird issues here. When I open the font dialog, the fullscreen mode is disabled - sigh is this our fault or the windows manager?

  9. Rui repo owner

    Rebased on top of the master branch and added minor fixes.

    I've seen a couple of minor issues with my window manager(i3) that disables fullscreen when vim opens a dialog window, but this seems to be i3's fault. As far as I can tell this will work as long as the X11 window manager respects the FULLSCREEN hint (i3, awesome, KDE seem ok).

    Some pending aspects:

    1. When in fullscreen the shell takes the whole window space by default, setting lines/cols reduces the shell size (and centres it). The only way to order the shell to fill the whole window is by setting a large number of lines/cols (e.g. :set columns=9999). This is the opposite of what macvim does.
    2. There is a fuopt setting just like in macvim, but currently there are no valid values for it. Later we may be able to use for some of the features we discussed earlier (background color, hide toolbar/menubar, size).

    I see no obvious reason not to merge this into the master branch as is. We can always pursue these aspects later.

  10. Rui repo owner

    Annoying issue, if we

    1. Place Vim in fullscreen mode :set fu
    2. Open a second tab
    3. Close the second tab

    The vim shell will remain slightly smaller than the itended size i.e. minus the tabbar height.

    The easiest fix is probably to store a size hint in e.g. :set fuopts

  11. Laurent George

    fuopts comments :

    I think fuopts could also be use to tweak the margin more precisely that just using columns..

    For example being able to say that upper margin should be 5 lines, bellow margin 2 lines, left margin 50 columns and right margin 40 columns.. would be great.

    It will allow to use vim as in "darkroom" or other focus editor .. and to still get something usuable when using it with a Taglist browser for instance..

    maybee not necessary, and really usefull for everybody, to be able to set different size for left and right margin but I think it would not cost a lot add it.

  12. Rui repo owner

    The question here is wich options should be passed, here are some sugestions

    • background:#ccc To set the background color around the shell
    • maxvert,maxhoriz Like macvim to force the shell to fill all the space - this is almost our current behaviour
    • columns:100,rows:1000 To set the size of the shell in lines/columns - but maxvert/maxhoriz would take precedence

    A few words about the last option. After trying to use fullscreen for while my general observation is that trying to overload the usual :set lines/columns is bad idea. For example try opening new tabs in fullscreen and then closing them again, the number of rows is never restore because we no longer know what was its previous values. By placing the row/colum size in fuopts the size of the console in fullscreen mode can persist across fullscreen changes. Am I making any sense?

    head7 suggested using margin values instead of shell sizes, e.g. :set fuopts+=top:10,bottom:10. My first doubt in that case would be to know which options take priority if setting margins resets the shell size? e.g.

    :set fuoptions+=columns:100
    :set fuoptions+=right:100

    Its possible that both options can't be respected, e.g. if the screen is 150 columns wide. My first instinct would be to disable conflicting options when another is set/unset.

    The default settings would be equivalent to (0 is not set):

    :set fuoptions=maxvert,maxhoriz,columns:0,lines:0,top:0,bottom:0,right:0,left:0

    If you set any horizontal options then all the conflicing options would be removed, i.e.

    :set fuoptions+=left:10

    implies that internally

    :set fuoptions-=maxhoriz
    :set fuoptions+=columns:0,rows:0

    Does this seems to be the direction we would like to take? I'm not entirely sure about the fuoptions ":" semantics but lets see how this goes.

  13. Rui repo owner

    One case I'm not sure how to detect/handle is whne the "margins" are too large for the vim shell to be displayed at all.

  14. H W Tovetjärn reporter

    I use the above script to toggle the fullscreen mode but could a command, e.g. :togglefullscreen, be implemented? The script assumes that it is not in fullscreen mode to begin with when called initially.

    let s:InFullScreenMode = 0
    function ToggleFullscreen()
        if s:InFullScreenMode == 1
            exe "set nofu"
            let s:InFullScreenMode = 0
            exe "set fu"
            exe "set columns=128"
            exe "set lines=128"
            let s:InFullScreenMode = 1
    command! ToggleFullscreen call ToggleFullscreen()
    nmap <leader>fs :ToggleFullscreen<cr>
  15. Log in to comment