Editor showdown: Maintain newlines at the ends of sentences

瘦欲@ 提交于 2019-12-04 04:07:04

I'd think the simplest solution to this is to only add newlines after full stops. Your edits would then never fragment lines.

Note that for prose you can very well rely on your editor's line-wrapping features to wrap long sentences - unless you insist on indenting it like you would with code (I don't indent that much in latex),

Vim:

You can turn off text-wrapping (set formatoption-=t) and it will not add linebreaks unless you hit enter. Better still, if you can figure out how to set up the 'comments' option so that it recognizes your comments, you can set an auto-wrap width only for your comments and not for anything else:

set comments=b:%
set textwidth=80
set formatoption+=c
set formatoption-=t

This is the method I use, so that my comments are tidy, but my code doesn't get mangled unless I do it myself.

A normal text editor should not attempt to change the file you write, unless you explicitly ask it to. It may change file's appearance on screen for readability, but that's it.

Therefore most decent editors in my experience do soft wrapping and keep your line breaks wherever you inserted them.

That's all. I must confess I can't see what the fuss is about, unless you are using some pretty weird text editors that insist on doing hard wraps and need workarounds.

If you want to keep formatting useful for diff, just do the line breaks after each sentence, and accept that diff will work on sentence level.

In vim, you can fill to the end of the current sentence with gw). It won't reformat an entire paragraph or region for you, but if you are careful to insert newlines after each sentence, and you reformat with gw) as you write, it works pretty well.

Whatever you do, please don't use an editor that automatically hard wraps the entire document if you're in a collaborative environment. Friends don't let friends use WinEdt.

I'd like to know how people deal with this in other editors,

FWIW on the Windows platform, the Zeus editor has a configurable right margin and a built in line wrap function.

So for example, with the right margin set to 60 characters, marking the text of your example and then using the Macros, Linewrap Paragraph menu, Zeus will reformat the text as follows:

As you edit the proseit will get all chopped up, 
like this. Normally you'd do a "reformat 
paragraph"to clean it up, but thenyou lose the 
newlines at the ends of your sentences!

The wrapping is hard in that all the lines above have a end of line character inserted.

you do not want newlines at the end of sentences.

sure it's easier to do the 4 things you list, but that is not worth doing it different from how the rest of the world does it (even if the world's reasons are as stupid as the reasoning behind CR LF = newline).

and your biggest advantage is not true:

Otherwise you end up with conflicts where it just informs you "the following two versions of this huge paragraph are in conflict".

How would it know when to be line-based and when to be sentence-based?

you can use Meld or some similar diff tool and let it do the work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!