Distraction-free writing on Linux

With Vim and GNU Screen

I’ve been playing around with Vim recently, and I’ve found it to be surprisingly good for writing prose, once I had got over the differences from normal word processors and text editors and had a basic .vimrc set up. I mark up my text with markdown and then run it through pandoc to create appropriate output (in the case of this blog I have it output to HTML, which I redirect to xclip and then paste into WordPress’ HTML view).

I’ve also been interested in trying out a distraction-free writing environment; but I’ve grown so used to using Vim that I just can’t go back (I can’t! Ah bloo hoo ho).

Now of course it is entirely possible to just use a fullscreen terminal with Vim running in it; but then the lines would be extremely long, which I would find unpleasant.

A few hours of googling found me nothing useful – there are a lot of attempts at kludgy workarounds involving obscure Vim commands, but I couldn’t get them to work.

Finally, I just asked a question over on stackexchange. From that and from another question on superuser.com, I have learned how to get what I wanted with another program called GNU Screen (if you have a SE account, go ahead and give all those answers an upvote). Screen is mostly intended for sysadmins and so on to run multiple terminals in a single terminal, but it is also perfectly suited to this task.

First, make sure you have Vim and Screen installed. Then, put the following in a file called .screenrc in your $HOME (/home/evilsoup/.screenrc for me). These commands will be run whenever an instance of Screen is started:

focusminsize 75 25
split -v
focus
only
split -v
split -v
focus
caption string "%{= dd} "
sorendition "="

Most of these lines (up until the final ‘focus’) do the ‘centring’ – you will end up with a ‘page’ in the middle of the terminal with a width of 75 characters (perfect for readability). The last two lines get rid of the white lines that would otherwise be on the bottom and either side of the ‘page’, since they are horribly distracting, by turning them the same colour as your terminal’s background.

I also have the following in my .vimrc:

syntax on
set wrap
set linebreak
set spell spelllang=en_gb
map <f5> :set spell! spelllang=en_gb <enter>

That turn on syntax highlighting, sets Vim to wrap on words, sets the spellchecker on by default (with English-English as the language) and means that F5 toggles spellchecking. For the kind of writing I do, this is enough; you may want more (or even less! Maybe you could have spellcheck and syntax highlighting turned off by default, for an even more minimal environment. You could get rid of Vim’s linecount and so on…).

An advantage of this method is that it can be seamlessly used with any terminal-based text editor. GNU Emacs, Nano, whatever.

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: