Indented soft-wrap

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Indented soft-wrap

mwean
My understanding is that soft-wrapped lines can now be indented, but I can't figure out how to enable that. Is this feature implemented?
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
On 15 Dec 2011, at 19:40, mwean wrote:

> My understanding is that soft-wrapped lines can now be indented, but I can't figure out how to enable that. Is this feature implemented?

Indented soft wrap is controlled via scoped settings. For example for the `markup.list.unnumbered` scope we could add a setting a la:

    {   indentedSoftWrap = {
            match  = '\A\s*[-*]\s+';
            format = '${0/\S/ /g}';
        };
    }

The `format` value is a format string which will be expanded based on the match and prepended to each wrapped line.

There are a few default settings e.g. for line comments and list items.


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Adam Strzelecki
> Indented soft wrap is controlled via scoped settings. For example for the `markup.list.unnumbered` scope we could add a setting a la:

Brilliant! TM2 takes Markdown editing to the whole new level. So it is just now the case of defining these for C/C++ scopes if we want softwraps within C/C++ language source files?

Cheers,
--
Adam Strzelecki


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
On 16 Dec 2011, at 00:36, Adam Strzelecki wrote:

>> Indented soft wrap is controlled via scoped settings. For example for the `markup.list.unnumbered` scope we could add a setting a la:
>
> Brilliant! TM2 takes Markdown editing to the whole new level. So it is just now the case of defining these for C/C++ scopes if we want softwraps within C/C++ language source files?

Yes, try e.g. after a line (in C/C++) and type: // lorem⇥

This will give you a nicely indented and soft wrapped comment despite the rest of the source being hard wrapped. Note though you need to also enable soft wrap for the scope for which you set the indented soft wrap preferences (if you want that scope to always be soft wrapped, regardless of document setting).



_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Trevor Harmon
In reply to this post by Allan Odgaard-4
On Dec 15, 2011, at 1:12 PM, Allan Odgaard wrote:

> On 15 Dec 2011, at 19:40, mwean wrote:
>
>> My understanding is that soft-wrapped lines can now be indented, but I can't figure out how to enable that. Is this feature implemented?
>
> Indented soft wrap is controlled via scoped settings. For example for the `markup.list.unnumbered` scope we could add a setting a la:
>
>    {   indentedSoftWrap = {
>            match  = '\A\s*[-*]\s+';
>            format = '${0/\S/ /g}';
>        };
>    }

That works great for the scopes where it's defined, but many of the scopes where I want soft wrap indentation (XML comments, Java source code) don't have it. As an alternative to inserting indentedSoftWrap in all the bundles I use, is it possible to specify a single global fall-back that performs a "dumb" soft wrap indentation (e.g., indenting to the same level as the previous line, or same level plus 1)? In other words, is there a way to tell TextMate that I want indented soft wrap *everywhere*? Thanks,

Trevor


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
On 16 Dec 2011, at 06:12, Trevor Harmon wrote:

> That works great for the scopes where it's defined, but many of the scopes where I want soft wrap indentation (XML comments, Java source code) don't have it. As an alternative to inserting indentedSoftWrap in all the bundles I use, is it possible to specify a single global fall-back that performs a "dumb" soft wrap indentation (e.g., indenting to the same level as the previous line, or same level plus 1)? In other words, is there a way to tell TextMate that I want indented soft wrap *everywhere*? Thanks,

The empty scope selector will match all scopes (and thus be the fallback).

And “same indent as last line plus one” could e.g. be:

  {   indentedSoftWrap = {
          match  = '\A[ \t]*';
          format = '$0\t';
      };
  }


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Steve King-8
In reply to this post by Trevor Harmon
On 2011-12-16 00:12, Trevor Harmon wrote:
> In other words, is there a way to tell TextMate that I want indented soft wrap *everywhere*? Thanks,

Similarly, is there a way to tell it I want soft wrap *nowhere*?  
Soft-wrapped comments are a neat trick, but they're not something I'd
generally want.  For example, I have some C files with wide tables in
the comments.  These should *not* be wrapped. If the scope overrides the
document setting, how can I then override the scope and tell TM2 that
really, don't wrap, I mean it?

--
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>



_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Adam Strzelecki
> Similarly, is there a way to tell it I want soft wrap *nowhere*?  Soft-wrapped comments are a neat trick, but they're not something I'd generally want.  For example, I have some C files with wide tables in the comments.  These should *not* be wrapped. If the scope overrides the document setting, how can I then override the scope and tell TM2 that really, don't wrap, I mean it?

I guess that would be hard, changing that for every possible language that defines such scopes, unless there's kind of CSS like !important scope selector or global option that turns soft wrap indent off.

Regards,
--
Adam

_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Trevor Harmon
In reply to this post by Allan Odgaard-4
On Dec 15, 2011, at 11:07 PM, Allan Odgaard wrote:

> The empty scope selector will match all scopes (and thus be the fallback).

Is there a "root" grammar that is global to all, so I can put my empty scope selector there and make it the fallback not just for a particular grammar but for all of them? If not I guess I could put it in the Source and Text bundles and that would take care of almost all cases.

Trevor


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

mwean
In reply to this post by Allan Odgaard-4
Allan Odgaard-4 wrote
And “same indent as last line plus one” could e.g. be:

  {   indentedSoftWrap = {
          match  = '\A[ \t]*';
          format = '$0\t';
      };
  }
I'm sure I'm missing something, but when I try that for the ruby scope (without the extra tab), it doesn't work. I got it working in the markdown bundle, so I don't know what's wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
In reply to this post by Steve King-8
On 16 Dec 2011, at 16:15, Steve King wrote:

> […] is there a way to tell it I want soft wrap *nowhere*?

You’d have to delete / disable the few places we enable soft wrap for a scope. Wrt. comment lines that’d be Bundles → Source → Settings. I don’t think we _enable_ it in other places, we do disable it for diffs embedded in Git commit messages, raw code blocks (e.g. in Markdown), maybe source / PHP embedded in HTML (or maybe that’s just a local setting here).

Note: In 2.0 one can disable bundle items but when done, the only way to enable again is to delete the tmDelta written to ~/Library/Application Support/Avian/Bundles/… (since the item browser doesn’t allow you to click disabled items).


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
In reply to this post by Trevor Harmon
On 16 Dec 2011, at 18:42, Trevor Harmon wrote:

> On Dec 15, 2011, at 11:07 PM, Allan Odgaard wrote:
>
>> The empty scope selector will match all scopes (and thus be the fallback).
>
> Is there a "root" grammar that is global to all, so I can put my empty scope selector there and make it the fallback not just for a particular grammar but for all of them?

You can place your settings in any bundle you like and its scope selector will be tested against all scopes, so if empty, it will target everything.

We recommend you create a personal bundle for your personal items.


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
In reply to this post by mwean
On 16 Dec 2011, at 19:02, mwean wrote:

> Allan Odgaard-4 wrote:
>>
>> And “same indent as last line plus one” could e.g. be:
>>
>>  {   indentedSoftWrap = {
>>          match  = '\A[ \t]*';
>>          format = '$0\t';
>>      };
>>  }
>>
>
> I'm sure I'm missing something, but when I try that for the ruby scope
> (without the extra tab), it doesn't work. I got it working in the markdown
> bundle, so I don't know what's wrong.

You need to enable soft wrap for the indented soft wrap to kick in.

This can either be done for the entire document (temporarily via View → Soft Wrap and permanently via .tm_properties) or via scoped settings — the latter should only be done when the soft wrap setting is only for a subset of the document.


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

mwean
Allan Odgaard-4 wrote
You need to enable soft wrap for the indented soft wrap to kick in.
I did have soft-wrap enabled, but I had put the setting in with the other indent settings, which apparently prevented it from working. When I moved it to its own setting file, it started working.
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Trevor Harmon
In reply to this post by Allan Odgaard-4
After spending some time with indentedSoftWrap, I noticed a behavior that I think is a bug, or at least incorrect. If you're on the first line of a soft-wrap indented scope, and you press the Down key to go to the next line, the cursor doesn't remain on the same column as expected. Instead, it jumps to the right by the amount of indentation. This happens only on the first line, and only if the soft wrap is indented. Is anyone else bothered by this?

Trevor

On Dec 15, 2011, at 1:12 PM, Allan Odgaard wrote:

> On 15 Dec 2011, at 19:40, mwean wrote:
>
>> My understanding is that soft-wrapped lines can now be indented, but I can't figure out how to enable that. Is this feature implemented?
>
> Indented soft wrap is controlled via scoped settings. For example for the `markup.list.unnumbered` scope we could add a setting a la:
>
>    {   indentedSoftWrap = {
>            match  = '\A\s*[-*]\s+';
>            format = '${0/\S/ /g}';
>        };
>    }
>
> The `format` value is a format string which will be expanded based on the match and prepended to each wrapped line.
>
> There are a few default settings e.g. for line comments and list items.
>
>
> _______________________________________________
> textmate mailing list
> [hidden email]
> http://lists.macromates.com/listinfo/textmate


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
On 19 Dec 2011, at 08:14, Trevor Harmon wrote:

> […] first line of a soft-wrap indented scope, and you press the Down key to go to the next line, the cursor doesn't remain on the same column as expected. […]

This is similar to http://lists.macromates.com/textmate/2011-December/033586.html

For indented soft wrap though it isn’t just about pixels because going from first to second line with caret where there is indent on second, will move the caret, and there’s then a question of whether it should be moved back when leaving the last line of the paragraph.


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Adam Strzelecki
> For indented soft wrap though it isn’t just about pixels because going from first to second line with caret where there is indent on second, will move the caret, and there’s then a question of whether it should be moved back when leaving the last line of the paragraph.

I believe he was talking about some other issue, if you enable soft-wrap indent and move cared down within the same wrapped source code line, caret goes right by the amount of indent defined in indentedSoftWrap. I'd expect it remain at the same horizontal position, as if I had indented the code manually by line break and spaces. At least this happens in my C++ source with indentedSoftWrap set in the bundle as you suggested in previous post. Surprisingly it does work well on Markdown's list indented soft-wrap.

BTW. Any chance to make PageUp/Down (pageDown: pageUp: selectors) working in next releases, I'd love to continue testing TM2 but I find myself hitting these buttons with no effect all the time.

Cheers,
--
Adam Strzelecki

_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Trevor Harmon
On Dec 19, 2011, at 9:02 AM, Adam Strzelecki wrote:

For indented soft wrap though it isn’t just about pixels because going from first to second line with caret where there is indent on second, will move the caret, and there’s then a question of whether it should be moved back when leaving the last line of the paragraph.

I believe he was talking about some other issue, if you enable soft-wrap indent and move cared down within the same wrapped source code line, caret goes right by the amount of indent defined in indentedSoftWrap. I'd expect it remain at the same horizontal position, as if I had indented the code manually by line break and spaces.

Yeah, I don't think this is the same as the CJK issue. I've attached a screenshot to illustrate the behavior I'm seeing. Here, the text is soft-wrap indented by a tab character (4 spaces). Say the cursor is between "od" and you hit Up. The cursor is now between "um", as expected. Hitting Down should then return you to "od", but it doesn't. It jumps to "em", exactly four spaces to the right. This is quite jarring and not the expected behavior, especially since this only happens on the first line and only with soft-wrap indenting.


Unfortunately this doesn't happen 100% of the time, so it's difficult to give the precise steps to reproduce consistently. But I find it happens routinely.

Here is the rule I use:

{ indentedSoftWrap = {
format = '$0\t';
match = '\A[ \t]*';
};
}

Trevor



_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Allan Odgaard-4
On 20 Dec 2011, at 09:15, Trevor Harmon wrote:

> On Dec 19, 2011, at 9:02 AM, Adam Strzelecki wrote:
>> On 19 Dec 2011, at 15:25, Allan Odgaard wrote:
>>> For indented soft wrap though it isn’t just about pixels […]
>> I believe he was talking about some other issue, if you enable soft-wrap indent […]
> Yeah, I don't think this is the same as the CJK issue […]

I was talking about indented soft wrap as well.


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Indented soft-wrap

Anthony V. Pulido
In reply to this post by Allan Odgaard-4
Hello everyone,

I've just installed TextMate 2 and have been trying to enable soft wrap indenting. I found this mailing list and I see that the setting

 {   indentedSoftWrap = {
            match  = '\A\s*[-*]\s+';
            format = '${0/\S/ /g}';
        };
    }

is required to enable it globally, but I'm not quite sure where to put it. If I knew what "empty scope selector" meant, that would be a great help. As a start, I thought I might try to enable it just for LaTeX, but have been unsuccessful. I've opened the Bundle Editor and inserted the above into the Miscellaneous preference in the LaTeX bundle, but soft wrapping, which is enabled, has not changed. Would anyone know what I've missed?

Anthony Pulido

Allan Odgaard-4 wrote
On 16 Dec 2011, at 06:12, Trevor Harmon wrote:

> That works great for the scopes where it's defined, but many of the scopes where I want soft wrap indentation (XML comments, Java source code) don't have it. As an alternative to inserting indentedSoftWrap in all the bundles I use, is it possible to specify a single global fall-back that performs a "dumb" soft wrap indentation (e.g., indenting to the same level as the previous line, or same level plus 1)? In other words, is there a way to tell TextMate that I want indented soft wrap *everywhere*? Thanks,

The empty scope selector will match all scopes (and thus be the fallback).

And “same indent as last line plus one” could e.g. be:

  {   indentedSoftWrap = {
          match  = '\A[ \t]*';
          format = '$0\t';
      };
  }


_______________________________________________
textmate mailing list
textmate@lists.macromates.com
http://lists.macromates.com/listinfo/textmate
12