You are not logged in.

#1 2008-01-21 17:30:01

gunnihinn
Member
From: Torreón, Mexico
Registered: 2007-10-28
Posts: 81

Writing with Emacs or Vim

I was just wondering, when you people write something like actual text, how do you deal with the line breaking in Vim and Emacs? Do you go old school and press Return at the end of every line, or is there some obscure option to have them break lines automatically?

The thing is, I very much like writing with either one as it seperates the actual writing from the presentation, but editing what you just wrote is a complete drag as all the keyboard shortcuts jump over entire paragraphs at once.

Last edited by gunnihinn (2008-01-21 17:30:46)

Offline

#2 2008-01-21 17:39:18

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Writing with Emacs or Vim

In Vim you can do

:set wrap lbr

This wraps the text but only breaks on white space.

I've never done this myself, but you can then remap the key bindings for the cursor keys to make the cursor navigation a little more sensible when wrapping is on.

http://vim.wikia.com/wiki/Move_through_wrapped_lines

Offline

#3 2008-01-21 17:59:14

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: Writing with Emacs or Vim

You could also use fold.
A command like: fold -c70 -s will break before 70 characters on a space.

If your editor supports it (probably), run the command on the text.
In ed you can do this:

w
e !fold -c80 -s %
w

Which will use the output of the fold command as the new buffer and also safe it.

(edit: need to safe it first though, fold will work on the file as it is on the hard disk, not the current buffer)

Last edited by Gilneas (2008-01-21 18:00:44)

Offline

#4 2008-01-21 17:59:16

bt
Member
Registered: 2007-04-11
Posts: 198

Re: Writing with Emacs or Vim

Run Cream instead of Vim amd wrap and unwrap are simplified as menu items.

Offline

#5 2008-01-21 18:22:32

gunnihinn
Member
From: Torreón, Mexico
Registered: 2007-10-28
Posts: 81

Re: Writing with Emacs or Vim

Thanks for the quick replies, the Vim shortcuts work beautifully.

I did a little honest googling and came upon this solution for Emacs:
http://penguinpetes.com/b2evo/index.php … &tb=1&pb=1

Offline

#6 2008-01-21 19:10:06

smurnjiff
Member
Registered: 2007-06-25
Posts: 211

Re: Writing with Emacs or Vim

If you are editing text, use this line in your .vimrc
autocmd FileType text setlocal textwidth=78 formatoptions+=t infercase

Offline

#7 2008-01-21 19:33:05

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: Writing with Emacs or Vim

I usually put in hard line breaks  (in Emacs, I just hit M-q to fill manually). I figure that if I'm typing it in a text editor, I'm going to view it with something that does not do automatic word wrapping, so I might as well make it presentable. If I'm typing a post to a forum or something, it's temporary and I don't bother with any fancy wrapping. I just let it wrap at whatever character hits the edge of the screen. There's no issue with movement keys because I've got a mouse for that.

If I were writing a novel or something, I'd also do hard line breaks for my own copy. It's easy enough to strip them later.

Offline

#8 2008-01-21 20:20:54

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: Writing with Emacs or Vim

In emacs, use the auto-fill mode to break lines automatically.  If your file has an extension recognized by emacs, it will automatically load the  auto-fill mode.

Offline

#9 2008-01-23 03:30:17

tesjo
Member
Registered: 2007-11-30
Posts: 164

Re: Writing with Emacs or Vim

With emacs I find auto-fill kind of usless because of hard breaks and I'll just have to reformat later. The solution posted by gunnihinn seems to soft wrap very nicely. Navigating hasn't really been an issue for me so emacs so I just let wrap at the end of the window. And if I want a printable copy I'll run

enscript -B --word-wrap file.txt -p file.ps

or of course open in a word processor.

Offline

Board footer

Powered by FluxBB