The Stripey Site

SLRN & Vim

SLRN is a newsreader available for Unix, Windows, and OS/2. This page details how to make it work well with Vim.

The Vim settings below are included in the sample .vimrc configuration file.

Calling Vim from SLRN

To invoke Vim as the editor from SLRN, a line like this should be in the .slrnrc:
set editor_command "vim -c 'set titlestring=SLRN\\ Vim' -c %d %s"
The %d makes Vim jump to the appropriate line in the file (though, somewhat curiously, this only happens the first time editing any file; when quitting Vim back to SLRN then editing the file again, the SLRN always seems to suggest the first line). The %s is the name of the file to be editied.

The titlestring changes the title of the terminal to “SLRN Vim”, which is generally more meaningful than the name of the file being edited. It ensures that the window can easily be identified as being the one in which SLRN is being run, even though SLRN isn’t currently visible.

Formatting Articles Nicely

Information on how Vim can format articles sensibly as you type is given in the section on formatting text files. Note that the gq reformatting keystroke generally works fine with quoted text, keeping the quotation characters in sensible places, even with multiple levels of quotation. To make this work with colon-quoted articles, see the section on formatting comments.

Better Positioning the Cursor

When composing a new news article without a signature, the cursor will be placed on the blank line after the header. It can be more convenient if another blank line is inserted ready on to which to start typing, so this can be done (by yanking then putting the blank line) in such situations, IE whenever .article is opened and the cursor is at the end of the file.

If there is a signature SLRN will insert an appropriate number of blank lines, but leaves the cursor on the third blank line after the header, rather than the more useful second. This can easily be rectified: because of the quirk mentioned above, whenever a file is being re-edited the cursor will be on the top line, so if .article is opened with the cursor neither on the first nor the last line then this must be the first time of opening an article with a signature, hence the cursor can be moved back one line. Putting all this together gives this autocommand:

autocmd VimEnter .article if line('.') == line('$') | yank | put |
  \ elseif line('.') != 1 | -

Ensuring That Attribution Lines Wrap

An attribution lines (such as “In %n, %r <%f> said:”) when can end up over 80 characters long once SLRN has instantiated it with the details of the article being followed-up. Somewhat ironically, SLRN can then object to posting the follow-up, on the basis that it contains a line that is too long! To fix this, have attribution lines wrapped to the current textwidth setting. This obviously must not happen if the article is being re-edited (wrapped article header lines tend not to be so useful!), so a check is made:
autocmd VimEnter .followup if line('.') != 1 | normal gq${j

Syntax Highlighting Postponed Articles

Postponed SLRN articles can have any name, so by default Vim cannot identify them and syntax highlight them appropriately. This can be done if all files in your particular postponed directory are identified as mail/news messages; for more details see the section on formatting text files.


Feedback is welcome via vim-www@stripey.com. © Copyright 2000 — see copying information for details.