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?
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.
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,
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).
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
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'; }; }
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
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.
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.
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.
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.
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
Hello everyone,
Success! I've enabled soft wrap indenting (+1 extra tab)!
For the newbies, like me, out there looking for the same, I'll write out the steps here for LaTeX, but the method probably generalizes to other languages. As pointed out already, leaving the scope empty enables the feature for all languages, so it likely matters little where the preference resides.
Note: This applies only to TextMate 2.
1. On the menu bar, select Bundles > Edit Bundles.
2. Within the Bundle Editor display, select LaTeX > Settings. Once here, a list of preferences indicated by a white P on a gray circle is seen.
3. On the menu bar again, click on New or press command-N. From the Bundle Editor display, TM will prompt you to choose what to create: bundle, command, setting, grammar, etc.
4. Click setting. An untitled setting will appear in the Bundle Editor window.
5. Name the new setting. I used "Soft-wrap indent."
6. Select the new setting if not already selected.
7. In the text field, paste
{ indentedSoftWrap = { format = '$0\t'; match = '\A[ \t]*'; }; }
This enables soft-wrap indent + 1 extra tab. For some reason, the following wouldn't work, which I think is supposed to be soft-wrap indent (without the + 1):
{ indentedSoftWrap = { match = '\A\s*[-*]\s+'; format = '${0/\S/ /g}'; }; }
8. If you wish to restrict this to a certain scope, it can be done in the drawer next to "scope selector." Leaving it blank will enable soft-wrap indentation for any text file.
9. Save the setting by pressing command-S and close the Bundle Editor.
10. Make sure soft wrap is enabled. (View > Soft Wrap). It might be necessary to reload any open files for the setting to take effect.
Enjoy!
Anthony
References: If not already obvious, the settings code comes from Allan Odgaard, who posted it to the list on Dec 15-16, 2011.
On Aug 2, 2012, at 7:27 PM, Anthony V. Pulido wrote:
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
-- View this message in context: http://old.nabble.com/Indented-soft-wrap-tp32983136p34248591.html Sent from the textmate users mailing list archive at Nabble.com.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
*I've found that to make it work globally* ... just add it to a bundle that is always loaded, regardless of 'language' / 'grammar' / 'theme' e.g. when I add the setting to the 'TextMate' bundle, it works everywhere... *now matter what I'm doing*
http://textmate.1073791.n5.nabble.com/file/n26496/2013-05-07_14-23-49.png
*I've also adjusted you setting code (with a simpler match value) to:* { indentedSoftWrap = { match = '\A[ ]*'; format = '$0\t'; }; }
*This gives me indented soft wrap with 1 tab...* http://textmate.1073791.n5.nabble.com/file/n26496/2013-05-07_14-28-07.png
*This code:* { indentedSoftWrap = { match = '\A[ ]*'; format = '$0'; }; }
*gives me indented soft wrap flush with the parent line...* http://textmate.1073791.n5.nabble.com/file/n26496/2013-05-07_14-30-57.png
*and this code:* { indentedSoftWrap = { match = '\A[ ]*'; format = '$0 '; }; }
*gives me indented soft wrap with 1 space...* (my personal preference) http://textmate.1073791.n5.nabble.com/file/n26496/2013-05-07_14-36-40.png
I'm not familiar with the pattern items or rules related to the 'match' and 'format' argument values... where may I read more about that?
-M
-- View this message in context: http://textmate.1073791.n5.nabble.com/Indented-soft-wrap-tp14224p26496.html Sent from the textmate users mailing list archive at Nabble.com.
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?
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,
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).
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 textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
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.
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,
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
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.