From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16229 invoked by alias); 10 May 2011 15:33:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16015 Received: (qmail 6368 invoked from network); 10 May 2011 15:33:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Tue, 10 May 2011 11:26:31 -0400 (EDT) From: "Benjamin R. Haskell" To: Richard Hartmann cc: zsh-users@zsh.org Subject: Re: Substituting grep (and other) output to open files in Vim In-Reply-To: Message-ID: References: User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Tue, 10 May 2011, Richard Hartmann wrote: > Hi all, > > I would like to be able to do the following, but I am stuck. Every > pair of lines is what I would execute and what it would be transferred > to. I am assuming that every file "name" (i.e. including colons etc) I > am running Vim on does not exist. If it exists, it should be opened > instead of magic happening. "foo" exists while "foo:" etc do not. > > vim foo: > vim foo > > vim foo:bar > vim foo > > vim foo:123 > vim foo +123 > > vim foo:123: > vim foo +123 > > vim foo:123:bar > vim foo +123 > > Ideally, the same would happen for vimdiff. And yes, vimdiff heeds > only one +n and the last one on the command line wins. That's fine. > > > I am pretty sure this is trivial to do in zsh, but as I said I am at a > loss as to how.. I'm at a loss as to "why". :-) What's the actual problem you're trying to solve? These don't seem like things you would want to type, so it looks like you're joining a bunch of parameters with colons only to want to separate them out to separate arguments later. If you keep them in an array in the first place, you don't have this problem. And maybe it'd be easier to get what you want. e.g. (without handling the ':bar' portion since I don't know what it would be) vimargs=( vim ) (( $+file )) && vimargs+=( $file ) (( $+line )) && vimargs+=( +$line ) $vimargs -- Best, Ben