[TxMt] Text width control
Charilaos Skiadas
cskiadas at uchicago.edu
Fri Mar 24 05:28:58 UTC 2006
On Mar 23, 2006, at 11:12 PM, Afternoon wrote:
>
> I always like to keep the length of lines down under 80 chars. I
> rarely edit in a window much wider that that, and even if I did it
> gets very hard for the eye to scan from end of line to the
> beginning of the next over 12-14 words. For example, when writing
> HTML, paragraphs are more easily read if they're not on one
> strapping great line and if indentation is correct. I'm aware of
> the Reformat Paragraph command, but this doesn't take structure or
> context into account. When writing code, long lines get
> complicated, perhaps they could be refactored to be simpler. As I'm
> a bit of a nerd, I appreciate the editor pointing out when I've
> exceeded the threshold and help me to refactor.
Well, with soft-wraps, the editor in a way *will* tell you that
you've exceeded the threshold, when it moves the pointer to the very
left end of the next line. :)
Alternatively, you can do the following, highly not recommended for a
number of reasons but nonetheless amusing "hack":
You can create, in each language in which you want the feature, a
scope, called maybe meta.toolong.yourlanguage, or even better
meta.illegal.toolong.yourlanguage
and set its regexp to detect a sequence of 78 characters with no
newlines. Using the word illegal there would color it as illegal
syntax, so that it quite an indicator I would say.
You could if you prefer create this scope in a new language, called
maybe source.general, and include it in any other language you want.
For extra credit, (even more hideous hack), you can create, for each
character, a snippet, with scope meta.illegal.toolong, which would
insert whatever you want it to insert.
Or, what is more reasonable, just bind return to one snippet that
inserts the appropriate thing. You can even have this snippet as a
command and have it common for all languages, and have it detect
which language it is using through the TM_SCOPE variable, and
accordingly insert the appropriate continuation character etc.
All this is quite far from ideal of course, for a number of reasons.
Once Allan implements dynamic scopes maybe there will be a more
elegant solution.
Haris
More information about the textmate
mailing list