Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Substituting grep (and other) output to open files in Vim
- X-seq: zsh-users 16014
- From: Jérémie Roquet <arkanosis@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Substituting grep (and other) output to open files in Vim
- Date: Tue, 10 May 2011 16:14:01 +0200
- Cc: Richard Hartmann <richih.mailinglist@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=CjosboCQcorXW9Do7SxRItz3hsBUtoxQ10D5HLJBFfo=; b=BQTZ3AdzRSTjuXLMbSBoFiemT14g6H5ne00Bl6dr8/DwsNhueP4KjUiun5kk0zuPxd j9LLYiWvm3XYAqmiXArBR5NglTmLG+//vTYLm1YR07dc0ernJR5elzbMgtE+F82PjVts AXs4xVIclFxh61KZyVq3C5EjZCF0ZdGE9hd14=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=AbUI3eyns3CCefDpyYL5Hbomb+fi+pBdaB9n5GoXJ5rONSFnnAcBPLBwbCmHHa0l6y rocakTCHwDbniirlrPzy07UJQbqsotzNeB8EawYxWUwDdYupo4bihN2CkxCv3Hrx0Oak nxs0gGSMaRFp1V0UYotldFRCgpvyUhTM7F4Tk=
- In-reply-to: <BANLkTik+65NedRoVNJMgj9+Oma_XDmz8dA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <BANLkTik+65NedRoVNJMgj9+Oma_XDmz8dA@mail.gmail.com>
Hi Richard,
2011/5/10 Richard Hartmann <richih.mailinglist@xxxxxxxxx>:
> 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..
Something like
vim() {
if test -r $1; then
command vim $1
else
args=(${(s.:.)1})
[[ $args[2] = <-> ]] && command vim $args[1] +$args[2] || command
vim $args[1]
fi
}
?
Best regards,
--
Jérémie
Messages sorted by:
Reverse Date,
Date,
Thread,
Author