I do most of my writing in Vim, because I’m a big nerd. It does most of what I want a writing environment to do, but I miss some of the “distraction free” features of the quite exceptional WriteRoom. Fullscreening Vim means that text ends up flat up against the left side of my monitor, but I’d much prefer it to be centered. I’d also like a little of the visual clutter to fade away. In other words, instead of this:
I’d like to work in this:
Some of this is possible with MacVim, but I’d rather do as much as possible in a platform-independent way. So, command-line Vim it is.
I think the best way to install Vim plugins is via Tim Pope’s Pathogen. Using that plugin, you can simply clone the VimRoom repository into your bundles
directory, and you’re done.
Without Pathogen, installation is almost as trivial: simply copy ./plugins/vimroom.vim
from the repository into your plugins
directory. That’s it!
By default, VimRoom binds <Leader>V
to <Plug>VimroomToggle
, and sets up an 80 column workspace with at least 5 columns of space on either side (it doesn’t help at all to have single-column sidebars, you see), and 3 lines of space above and below. It assumes a black background when hiding visual distractions. As of v0.4, VimRoom also sets up a :VimroomToggle
command that has the same effect.
Changing any of these assumptions is a simple matter of setting variables in your .vimrc
.
g:vimroom_background
is the background color to be used for hiding elements. Set this to your terminal’s background color (“white”, “black”, etc.)g:vimroom_min_sidebar_width
is the minimum sidebar width. This will automatically expand to take up all the free space left after setting the main workspace window to g:vimroom_width
columns.g:vimroom_navigational_keys
determines whether Vimroom will map keys like <Up>
, <Down>
, j
, and k
to navigate over “display” lines, rather than “logical” lines. This defaults to 1 (on), if you’d prefer the mapping not take place, set it to 0 (off).g:vimroom_scrolloff
specifies how many lines of text ought appear before and after the cursor. This defaults to 999, which centers the cursor on the screen.g:vimroom_sidebar_height
sets the height of the upper and lower “sidebars.” If you don’t want vertical padding, set this to 0.g:vimroom_width
is the width of your workspace.You can bind the <Plug>VimroomToggle
function to any key combination you like via the usual mechanisms. For example:
nnoremap <silent> <Leader>mz <Plug>VimroomToggle
Would bind the function to <Leader>mz
. Trivial, right?
And that’s it!
g:vimroom_navigational_keys
option
to enable users to determine whether navigational keys ought to be mapped
as navigating over “display” lines instead of “logical” lines. I also
wrapped the mappings in a try/catch block, just in case.Changed navigation mappings in Vimroom mode to move over wrapped lines
as they’re displayed on the screen (“display lines” in Vim vernacular)
as opposed to the default navigation over hard line-breaks (“logical
lines”). These mappings are only implemented if j
/<Down>
and
k
/<Up>
aren’t already mapped to something else.
Explicitly setting textwidth
when toggling Vimroom.
Turning off display of cursorline
in the various padding windows.
Renaming the <Plug>Vimroomize
mapping to <Plug>VimroomToggle
(as
Vimroomize
is a silly name)
Adding a :VimroomToggle
command that has the same effect as the
<Plug>VimroomToggle
mapping.
Vertical padding is available now via the g:vimroom_sidebar_height
configuration option, which defaults to 3 lines.
Finishing the initial feature set
Clearing the status bar
Adding toggle functionality (executing <Plug>Vimroomize
a second
time will get you back to “normal” vim mode with the color scheme
reset, and all secondary windows closed..)
Initial public release.