Not signed in (Sign In)

Categories

Vanilla 1.1.1 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorsilentrob
    • CommentTimeJan 30th 2007 edited
     permalink
    Is there a way to wrap selected text in a snippet ?

    I would like to copy text so:
    line one
    line two
    line three

    Then select it, and insert a multiline snippet like so:
    <li>line one</li>
    <li>line two</li>
    <li>line three</li>

    I guess it could be though of like muli line indending or commenting etc...

    If this dosent exsit, I can move it to a request.

    Thanks

    Rob E
    • CommentAuthori
    • CommentTimeJan 30th 2007
     permalink

    Nope, no way to do this for the time being due to the absence of a variable storing the currently selected text.. as Textmate does. I’ll put this up on the feature requests list.

    Maybe centi can move this thread over there so that you won’t have to create another thread :) And welcome to the Intype forums!

    • CommentAuthorsilentrob
    • CommentTimeJan 30th 2007
     permalink
    Great, Im looking forward to mastering intype!

    Thanks again.
    • CommentAuthorcenti
    • CommentTimeJan 31st 2007
     permalink

    silentrob: try to move this thread into Feature request category yourself. Just edit your first comment in this thread and select the other category. I’m just curious whether a regular forum member is able to move threads like this, or only admins can do that.

    • CommentAuthorsilentrob
    • CommentTimeJan 31st 2007
     permalink
    Yep, Anyone can move a thread.

    Rob
    •  
      CommentAuthorFrederick
    • CommentTimeJan 31st 2007
     permalink

    idyllrain: Nope, no way to do this for the time being due to the absence of a variable storing the currently selected text.

    I actually think this is already possible, but I may be mistaken…

    • CommentAuthorBrendonKoz
    • CommentTimeJan 31st 2007
     permalink

    Check the HTML bundles for examples. When using the HTML bundle I just noticed you can wrap some selected items in tags (such as a hyperlink).

    •  
      CommentAuthortstrokes
    • CommentTimeJan 31st 2007
     permalink

    Yeah you can use the variable $SELECTED_TEXT.

    • CommentAuthori
    • CommentTimeJan 31st 2007 edited
     permalink

    Ah…. pardon my ignorance… There’s another variable that I encountered while fixing/rewriting the C/C++ snippets, $FILE_NAME, but it doesn’t seem to be working tho.

  1.  permalink

    FILE_NAME and many other variables will be added in the next release. Wrapping each line in snippet is not possible now. You can wrap selected text, but not each line. This will be handled by scripts.

    • CommentAuthori
    • CommentTimeFeb 1st 2007 edited
     permalink

    martincohen: Wrapping each line in snippet is not possible now. You can wrap selected text, but not each line. This will be handled by scripts.

    Mm, I’m not quite sure what you mean, but if you mean wrapping each line of selected text, well… its possible. Since the regex replacement works, and that we have the $SELECTED_TEXT variable, we can replicate the same behavior silentrob asks… as shown by the snippet below:

    { title: 'Test wrap' key_equivalent: 'Ctrl+/' scope: 'source.html' content: '${SELECTED_TEXT/(^\s*)([^\r\n\f]+)/$1<li>$2<\/li>/g}' }

    To test this, just enter some lines of text in Intype, select them, then choose this snippet from the menu (or just press the shortcut key if your language grammar is already HTML).

    Edit: Modified the regex to better match non word characters and the like….

    • CommentAuthorsilentrob
    • CommentTimeFeb 1st 2007
     permalink
    That is PERFECT! Wow, uber cool!
    This tool just got more powerful!

    I think i need to brush up on my reg expressions and maybe lua while Im at it.

    This might be off topic, but Ive seen some snippets where you can grab content from the clipboard. (html.wrap_selection_as_link)

    I can't get that to work or maybe I'm not doing it right... Does that work for anyone else? It if is a problem I can re-post under bugs.

    Rob
    • CommentAuthori
    • CommentTimeFeb 1st 2007 edited
     permalink

    :) Mm.. yeah.. I am aware of the HTML snippet in question. Well… Warp Selection as Link snippet uses another executable “pbpaste” to get stuff from the clipboard, along with some other shell commands that would allow the snippet to work on Macs. Martin will implement this for Intype in future releases… so we’ll just have to wait :)

    The bundles are TextMate converted bundles, there are some bugs and nasty things.. but not to worry.. some of us are working on them :) You can contribute too if you want :)

  2.  permalink

    Yep, that’s good solution, but there’s more power with scripting. You can for example wrap each line in a snippet, so you will be able to dynamically change the tag name in the editor.

    •  
      CommentAuthortstrokes
    • CommentTimeFeb 1st 2007
     permalink

    Yeah Lua is a great language but correct me if I’m wrong martin aren’t you guys going to use javascript for scripting.

    • CommentAuthori
    • CommentTimeFeb 1st 2007
     permalink

    Yeah… martin mentioned it in this post

    • CommentAuthordiane
    • CommentTimeFeb 15th 2007
     permalink
    "You can for example wrap each line in a snippet, so you will be able to dynamically change the tag name in the editor."

    Oh please tell me how! I looked at the snipped for wrap text with open/close tag, and it wraps in a p tag. What would change my life is if I could select, wrap, and then say h1, h2, ul, etc. I have no scripting skills, but am a quick study!
    • CommentAuthori
    • CommentTimeFeb 15th 2007 edited
     permalink

    Diane, although it wraps it in a p tag, you do know that you can type in a tag name and have it mirror at the ending tag right? ;)

    • CommentAuthordiane
    • CommentTimeFeb 15th 2007
     permalink
    Oh! It just gets better and better. How do I learn all these neat little things it does?
    • CommentAuthordiane
    • CommentTimeFeb 15th 2007
     permalink
    Do you know why I get two options? Wrap selection in open/close tag 1 and then an identical with a 2. I only see the snippet once in the bundles file, and I'd rather have it just wrap and then type the tag.
    • CommentAuthori
    • CommentTimeFeb 15th 2007
     permalink

    Two options? Could you post a screenshot of that?

    Yes, thats what the snippet does. :) Just select some text, press Ctrl + W, then type the tag. ;)

    And as for learning it, you could refer to the Textmate snippets manual I linked in the other thread, and take a look at the snippet files themselves. You can just ignore the “Interpolated Shell Code” part of the Textmate manual. The rest are identical or almost identical (in the case of the “Variables” section: we use $SELECTED_TEXT instead of $TM_SELECTED_TEXT). Martin and co are already planning for the Intype documentation, so we’ll have our own reference in a while :)

    • CommentAuthordiane
    • CommentTimeFeb 15th 2007
     permalink
    How do I post a image?
    •  
      CommentAuthortstrokes
    • CommentTimeFeb 15th 2007
     permalink
    Put it up on imageshack or esnip or something and then link to it using the textile syntax
    "Link Name":http://link