Hi,
I noticed some weird indentation problem when using "Insert as Snippet" as the output for a command. I reduced it to a simple test case (at least I hope):
Make a command with Output: "Insert as Snippet" Command: echo -n "$TM_SELECTED_TEXT"
Example text: ✂------✂------✂------✂------ - list1 [tab]- indented list2
paragraph 1 paragraph 2 ✂------✂------✂------✂------
If I select the text somewhere in the first line to the end and run the command, nothing changes, which is good.
If I select the text somewhere after the tab in the second line to the end I get this:
✂------✂------✂------✂------ - test list [tab]- test indented list
[tab]paragraph 1 [tab]paragraph 2 ✂------✂------✂------✂------
If I use "Replace selected text" instead, this doesn't happend. So, if I understand this right: When a command inserts a snippet on a indented line, everything in the snippet is indented. Why? Just in case, I deselected "Re-indent pasted text" in the prefs, still the same.
Am I missing something?
Thanks
-- FredB
On 27 Mar 2007, at 00:24, Fred B wrote:
Hi,
I noticed some weird indentation problem when using "Insert as Snippet" as the output for a command. I reduced it to a simple test case (at least I hope):
When using “insert as snippet” text is automatically indented using the indentation rules of the active language (as with pasting with re- indent, although it seems disabling that doesn't disable this functionality). 99% of the time that's what you want.
You didn't specify the language, but perhaps the issue (if there is one?) is to do with the indentation rules, I didn't really follow…
On 3/27/07, Ciarán Walsh ciawal@gmail.com wrote:
On 27 Mar 2007, at 00:24, Fred B wrote:
Hi,
I noticed some weird indentation problem when using "Insert as Snippet" as the output for a command. I reduced it to a simple test case (at least I hope):
When using "insert as snippet" text is automatically indented using the indentation rules of the active language (as with pasting with re- indent, although it seems disabling that doesn't disable this functionality). 99% of the time that's what you want.
You didn't specify the language, but perhaps the issue (if there is one?) is to do with the indentation rules, I didn't really follow…
Thanks Ciarán,
Language is markdown. I don't know if there is a problem with indentation rules or not, anyway I don't want indentation. ;)
Is there a way to disable this?
-- FredB
On Mar 26, 2007, at 7:57 PM, Fred B wrote:
On 3/27/07, Ciarán Walsh ciawal@gmail.com wrote:
On 27 Mar 2007, at 00:24, Fred B wrote:
When using "insert as snippet" text is automatically indented using the indentation rules of the active language (as with pasting with re- indent, although it seems disabling that doesn't disable this functionality). 99% of the time that's what you want.
You didn't specify the language, but perhaps the issue (if there is one?) is to do with the indentation rules, I didn't really follow…
Thanks Ciarán,
Language is markdown. I don't know if there is a problem with indentation rules or not, anyway I don't want indentation. ;)
Is there a way to disable this?
Yes, don't use "Insert as snippet" ;)
I'm afraid that's how that command works, because as someone said already this is what you want most of the time.
The problem has to do with the markdown syntax I think, in that it can't easily tell that the paragraphs are not a continuation of the test list. So I don't know if there is an easy way around it. Perhaps Jacob or someone else more knowledgeable in the markdown syntax can give us some more details.
Do you really need the snippet functionality in your case, i.e. "Replace selected text" wouldn't do it? What is the overall problem you were trying to solve?
-- FredB
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 3/27/07, Charilaos Skiadas skiadas@hanover.edu wrote:
On Mar 26, 2007, at 7:57 PM, Fred B wrote:
Is there a way to disable this?
Yes, don't use "Insert as snippet" ;)
It's the only way to have a snippet at the end, AFAIK. ;)
I'm afraid that's how that command works, because as someone said already this is what you want most of the time.
The problem has to do with the markdown syntax I think, in that it can't easily tell that the paragraphs are not a continuation of the test list. So I don't know if there is an easy way around it. Perhaps Jacob or someone else more knowledgeable in the markdown syntax can give us some more details.
Do you really need the snippet functionality in your case, i.e. "Replace selected text" wouldn't do it? What is the overall problem you were trying to solve?
I solved it. But the solution might help someone so:
I realized my macros to make reference-style links and footnotes in markdown were messed on indented lists.
How it was done:
- Start the macro rec. with the word selected. - Add brackets - Select text from there to the end - Run a command that parse the selected text to find highest reference link number then insert a snippet with an higher ref number, the clipboard for the link, etc. and ability to tab through placeholders to change them.
The workaround:
- Almost the same except I insert a dummy string just after the brackets - parse the entire document in the command using the dummy string to split it, etc.
May be not really academic, but it works. ;) Same for Google and Wikipedia links, footnotes, etc.
I can share them if someone is interested.
Thanks for your time.
-- FredB
On 3/27/07, Charilaos Skiadas skiadas@hanover.edu wrote:
On Mar 26, 2007, at 7:57 PM, Fred B wrote:
Is there a way to disable this?
Yes, don't use "Insert as snippet" ;)
open the plist/tmCommand file of your command and insert the following <key>disableOutputAutoIndent</key> <true/> a nicer way than using macros, IMO.
Joachim Mårtensson
On Mar 26, 2007, at 11:07 PM, Joachim Mårtensson wrote:
On 3/27/07, Charilaos Skiadas skiadas@hanover.edu wrote:
On Mar 26, 2007, at 7:57 PM, Fred B wrote:
Is there a way to disable this?
Yes, don't use "Insert as snippet" ;)
open the plist/tmCommand file of your command and insert the following <key>disableOutputAutoIndent</key>
<true/> a nicer way than using macros, IMO.
Huh, and I thought I knew everything about TM by now ;) It's been there for almost a year as well ;)
Joachim Mårtensson
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 3/27/07, Joachim Mårtensson joachimm@etek.chalmers.se wrote:
On 3/27/07, Charilaos Skiadas skiadas@hanover.edu wrote:
On Mar 26, 2007, at 7:57 PM, Fred B wrote:
Is there a way to disable this?
Yes, don't use "Insert as snippet" ;)
open the plist/tmCommand file of your command and insert the following <key>disableOutputAutoIndent</key> <true/>
Nice one! Thanks.
-- FredB