From cskiadas@uchicago.edu Fri May 19 00:39:41 2006 From: Charilaos Skiadas To: textmate@lists.macromates.com Subject: Re: [TxMt] unordered list nav snippet Date: Thu, 18 May 2006 19:40:18 -0500 Message-ID: <6CA09B14-62A5-480D-9BB2-398AA47F54E4@uchicago.edu> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5106017509517089798==" --===============5106017509517089798== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On May 18, 2006, at 7:32 PM, Dave Foy wrote: > I'm having trouble creating a custom snippet that, for me, would be > really useful. > > I want to set up a snippet to create an unordered list nav from a > plain text list, e.g. > > foo > bar > coo > tar > > I'd like to highlight the whole list, hit a key combo, which would > wrap each list item in
  • , wrap the whole lot in
      , and even > wrap the text within each list item in for good > measure. > > Can anyone help? This should get you started, i.e. you should be able to easily modify it to do what you want it to, even if you don't know much ruby. Create a command with input selected text with fallback line, output replace selected text (or possibly insert as snippet if you want to do something more clever) and text: #!/usr/bin/env ruby # print "
        \n" STDIN.read.each_line { |x| print "\t
      • \n\t\t

        #{x.chomp}

        \n\t
      • \n" } print "
      \n" I hope this is (at least relatively) clear and you should be able to modify it to do stuff. the syntax #{x.chomp} which might seem familiar tells Ruby: "I know you are inside a string now, but execute the thing in the {} as a ruby program and put its output in the string right here". x.chomp returns the string x with the possible newline removed. > Many thanks in advance. Haris --===============5106017509517089798==--