help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: soft wrapping and line numbers


From: address@hidden
Subject: Re: soft wrapping and line numbers
Date: Wed, 30 Apr 2003 14:20:29 -0400
User-agent: KNode/0.7.1

Eric Carlsen wrote:

> I recently started using emacs and I was wondering if there is a way to
> do some things. For one, is soft word wrapping implemented yet? By this
> I mean that there are no newlines inserted in text but it wraps lines on
> the screen without breaking up characters. Vim does it with lbr (I'm not
> trying to flame, just give background) and I think it is commonly done
> in the windows world.
> 
> The other feature I would like is to have the line number written beside
> each line. Is that possible? Thanks for any help. I've tried to read the
> manuals and look online but I haven't found any solutions yet.


The lack of a true word wrap with Emacs is my mine gripe with it. (This may 
only apply to writers.) But I've worked out a workaround. One no one else 
in the world will probably use. But here it is.

First, there's the Refill command. This works like the Fill command but it 
will REfill when you type something back in the middle of a filled 
paragraph. In other words, you don't have to M-q. It works pretty well, 
except . . .

It won't let you line up short lines. It'll greedily join them together. If 
you try to do this:

One or
two words
on a line.

You'll end up with:

One or two words on a line.

This is why I bound it to a function key so I could toggle it on and off 
when I make lists.

Refill also has problems with tabs--indenting everything.

But it works pretty well by typing out things with the TeX and friends 
method. That is, no tabs and double-spacing between each paragraph. 
(Ironically, refill conflicts with AucTex itself. You can't use it.)

That's not a bad way to work if you're like me and tend to hit the caps lock 
when you're reaching for the tab key. But if you want your text to have 
proper tabs you can do my Handy-Dandy, Patented, Kludgey, Little Genius 
Workaround.

I made a macro which converts two newlines in a row using replace-regexp to 
a tab and carriage return plus converts ALL single newlines to spaces so 
the individual lines within the paragraph join together. I also did another 
sweep to convert two spaces to one space, in case I ended up with too many 
between words.

I don't know how fast it would work on something the length of a book, but 
for the short news stories I write, it's done in a second.

After this activates you'll have tabs and long lines again. That's how I 
save everything since it facilitates a grep search. But if you call up that 
file on another day you'll have a problem because of the tabs. I made a 
companion macro that takes out the tabs and puts in newlines for this 
reason.

It never fails to irritate me that the most advanced editor on the planet 
can't do a job that Windows Notepad can handle. I'd really like that on my 
wishlist, but I doubt I'd be the first. There may be some reason it won't 
work. The other thing I wish would be incorporated would be the automatic 
capitalization at the beginning of sentences. There's an add-on out there 
that'll do it. I haven't tried it.

This is getting a bit long but I need to say something else about refill. 
The macro I just described won't work if you need paragraphs like you see 
here or a single-line list, like the "one or two words" thing I did above. 
I have to run a different series of finds and replaces to keep the 
double-spacing but make the long lines. It's nice that Emacs makes macros 
so easily.

Dunno if this helps.

--Rod

-- 
Author of "Linux for Non-Geeks--Clear-eyed Answers for Practical Consumers" 
and "Boring Stories from Uncle Rod." Both are available at 
http://www.rodwriterpublishing.com/index.html

To reply by e-mail, take the extra "o" out of my e-mail address. It's to 
confuse spambots, of course.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]