I've been using WriteRoom for a while for all my distraction free writing needs. But since I recently decided to move to Vim (or more specifically, MacVim) I've tried to reduce my usage of other text editors.

Vim can reproduce most of the features of WriteRoom, but the only one that prevents me to switch is the "typewriter scrolling" mode. For those who haven't used WriteRoom, this feature lets you write always on the same line (much like a typewriter) so you are always focussed on what you are writing and not distracted by what you have written. All the text scrolls up when you start a new line.

I've done my homework by googling everything that I thought was related, but I only found "plugins" and other Vim configurations which are making Vim look like WriteRoom but never provided the holy feature (maybe I've looked with the wrong keywords because I'm not a native speaker).

Although I found this article saying that it's possible with a simple setting I couldn't make it work, be it in the Terminal or in MacVim... If that works for you, I'd be glad to hear how (I've started with a blank .vimrc maybe you need to active some other stuff).

This feature is not very useful when it comes down to code, so I wouldn't be surprised if it wasn't possible out of the box. In this case, if you have any leads on how I could script that (even though I'm not familiar with scripting Vim, I can look into it), then I might try to make a small plugin for that.

  • What is the difference to the normal behaviour of vim? If you are on the last line and press enter or wrap around, the text scrolls up and you keep writing on the last line. – Nikodemus RIP Dec 15 '11 at 12:43
  • The difference is that the last line I am talking about is in fact in the middle of the screen so you never have to scroll or look down. You stare at the same line all the time while writing. Although you're right, if you reduce the window to half the size and write on last visible line, then you'd be able to reproduce the behaviour. It's just not exactly what I was looking for. – MathieuLoutre Dec 15 '11 at 13:26

set scrolloff=999 has been working perfectly, here but I found it annoying in the long run.

It doesn't depend on anything else beside Vim not being in compatible mode. Simply adding it to your ~/.vimrc is enough.

  • Ok, I reset everything and just add the scrolloff and the nocompatible mode in the .vimrc and it seems to work although it doesn't reproduce the feature in WriteRoom fully. The problem now is that it does write everything on the same line, but this line is not always in the middle of the screen. This behaviour is somewhat more flexible but is there any way to force the cursor at the middle of the screen now? Thank you very much for answering! – MathieuLoutre Dec 15 '11 at 13:31
  • Just so you know, set nocompatible is not needed: it is implied by the presence of a ~/.vimrc. I don't think it's possible to stay in the middle when on the first lines of the document. – romainl Dec 15 '11 at 14:10
  • The behaviour I would like is the following: Write normally until you hit the middle, and from the middle no being able to move the cursor down (every line skip will put the cursor on the same line (middle of the screen)). Do you think it's scriptable? If so, any ressources to point to? Anyway, cheers for following the answer :) – MathieuLoutre Dec 15 '11 at 14:23
  • Well, the behaviour you describe is exactly what I get with set scrolloff=999. – romainl Dec 15 '11 at 16:13
  • Ok, I should probably give it one more go before fiddling with scripting I guess. Thank you again! – MathieuLoutre Dec 15 '11 at 19:17

I tried set setscrolloff=999, which appears to be the official solution to this, but as noted in the comments, it only worked for me after creating lines ahead of the cursor.

I've only been using Vim for a week, so I'm not an expert and I don't know if this is the best alternative, but you could add :inoremap <CR> <CR><Esc>zzi to your vimrc. At least that way your current line (i.e. paragraph) is always centered once you reach the middle of the screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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