Hack for centering text horizontally in fullscreen mode?

128 views
Skip to first unread message

russmcb

unread,
Oct 21, 2011, 10:31:13 PM10/21/11
to vim_mac

Anyone have a hack we can use to put text into the center of the
screen when going into fullscreen mode? Currently, you have to turn
to the left to see your content when in full-screen mode. Bonus
points for automatically increasing the font size in fullscreen mode.

Carlos Galdino

unread,
Oct 22, 2011, 11:24:45 AM10/22/11
to vim...@googlegroups.com
Well, I tried to create a function to enter/leave fullscreen mode but I still don’t know why it doesn’t work very well.

But here is the function in case you want to try yourself: https://gist.github.com/1272896

If you have any luck, tell me. =)

-- 
Carlos Galdino
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Russ McBride

unread,
Oct 22, 2011, 1:53:42 PM10/22/11
to vim...@googlegroups.com

Thanks Carlos,

Vimscript is almost enough to make me switch over to emacs or use one of the vi modes for emacs like viper or evil… but that's a different topic….

What I found is that for my needs the simple solution was to just get rid of this line from my .gvimrc file (or comment it out):
set fuoptions=maxhorz,maxvert

Now, when I switch into fullscreen, MacVim automagically goes max vertical and centers horizontally, with the column width set to whatever the window width was set to before I went fullscreen.  Nice.  And simple.  Of course, this doesn't help you if you want a standard column width *whenever* you go into fullscreen mode.  But it shouldn't be too hard to get your script working for that purpose.

cheers,
russ

Andrew Stewart

unread,
Oct 23, 2011, 3:37:03 AM10/23/11
to vim...@googlegroups.com

On 22 Oct 2011, at 19:53, Russ McBride wrote:
> Vimscript is almost enough to make me switch over to emacs or use one of the vi modes for emacs like viper or evil… but that's a different topic….

Yes, it's suboptimal to say the least. However you can mitigate the pain by scripting Vim in Ruby, Python, Perl, etc, with a little boilerplate Vimscript wrapper.

Yours,
Andy Stewart
-------
http://airbladesoftware.com

Andrew Stewart

unread,
Oct 24, 2011, 2:50:53 AM10/24/11
to vim...@googlegroups.com

On 22 Oct 2011, at 19:53, Russ McBride wrote:
Vimscript is almost enough to make me switch over to emacs or use one of the vi modes for emacs like viper or evil… but that's a different topic….

Giovanni Lanzani

unread,
Oct 24, 2011, 8:43:14 AM10/24/11
to vim...@googlegroups.com
I did just that, comment out 

    set fuoptions=maxhorz,maxvert

however that didn't do the trick

björn

unread,
Oct 24, 2011, 10:09:11 AM10/24/11
to vim...@googlegroups.com

You need to

set fuopt=maxvert

See ":h 'fuopt" for more information.

As for changing font size and number of columns when toggling
full-screen, try adding these three lines (re-join them so that they
form three lines in case they have been split when I posted them) to
your ~/.gvimrc:

----- 8< ----
set fuopt=maxvert

command! ToggleFullScreen if &fu|set gfn=Menlo:h13|set co=80|set
nofu|else|set gfn=Menlo:h18|set co=120|set fu|endif

an <silent> Window.Toggle\ Full\ Screen\ Mode :ToggleFullScreen<CR>
----- >8 ----

Note that I've had reports that changing 'co' and 'fu' at the same
time can fail so I can't guarantee that the above works. However,
I've just tested it and it works fine for me. Also note that in order
for it to work you have to enter full-screen by using the menu, or by
pressing the shortcut for the menu (which should be Cmd+Ctrl+f unless
you are using an old version of MacVim).

Björn

Russ McBride

unread,
Oct 24, 2011, 3:03:23 PM10/24/11
to vim...@googlegroups.com

Thanks, Björn.

Doing this works fine:
set fuopt=maxvert

But the default is maxvert so it's good as is. And it's nice to have the width in fullscreen get set to the same as whatever you set in non-fullscreen. Being able to set the width by just mouse dragging in lion is nice.

I didn't know about gfn. Cool.

I'm assuming your command go inside this block:
if has("gui_macvim")…

When I do that, I can't go into fullscreen. When I keep them outside of that block, they don't do anything (but I can go into fullscreen).

Can someone give me a pointer to vim scripting? Maybe this 5-part series:
http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html

On another note, the best thing I ever did for Vim productivity was to switch my caps lock key to esc. I used this:
http://pqrs.org/macosx/keyremap4macbook/extra.html


Cheers,
russ

Reply all
Reply to author
Forward
0 new messages