Skip to content

Instantly share code, notes, and snippets.

@amacdougall
Created March 6, 2012 23:38
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amacdougall/1989803 to your computer and use it in GitHub Desktop.
Save amacdougall/1989803 to your computer and use it in GitHub Desktop.
Simple vim script for a single centered text column.
" Name: focus.vim
" Author: Alan MacDougall <smoke@alanmacdougall.com>
" License: Public Domain
"
" Focus on a single column of text, showing it in a distraction-free format.
" Save this as ~/.vim/scripts/focus.vim (or whatever you please), and invoke
" it with :source <filename>. Of course, you could certainly hook that up to a
" :command, or a macro, or a Vimscript function...
" collapse current splits and divide screen in three
only
vsplit
vsplit
"
" hide the tildes for nonexistent lines
hi! NonText guifg=bg guibg=bg
" hide the vertical split borders
hi! VertSplit guifg=bg guibg=bg
set laststatus=0 " hide status bar
set noruler " hide ruler [I prefer to leave this out]
enew " edit new blank file, i.e. clear screen
set nocul " hide cursor line highlight, if present
2wincmd l " move to right-hand split
enew
set nocul
wincmd h " move to center split; happy typing!
@amacdougall
Copy link
Author

Screenshot:

one column; writing zen

@amacdougall
Copy link
Author

Just open a new gvim/MacVim window before doing this, since there's no provision for reversing the effect!

@millermedeiros
Copy link

there is also the VimRoom plugin

@amacdougall
Copy link
Author

Yeah, this little script is very specific to my own setup and needs. I'm really fortunate that MacVim fullscreens at greater than 80 * 3 + 2 columns on my 27" iMac, for instance, meaning my centered column is wide enough for an 80-column text view. To universalize it would involve enough work to where VimRoom is probably a better solution. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment