shortcut for ex ranges

0 views
Skip to first unread message

Efraim Yawitz

unread,
Sep 28, 2008, 9:53:14 AM9/28/08
to vim...@googlegroups.com
Hi,

After reading the thread on asynchronous processes I was just looking
at the help for the ! command which I rarely use, and after playing
with it I realized that it translates a motion from normal mode into a
range for an ex command, i.e. doing !2j gives you an ex command line
of :.,+2! to start your filter with. This made me wonder: Is there a
way to do this without the filter? In other words, instead of having
to type :.,+2s I could get there with a 2j combined with something. I
realize I can do it with the ! itself by just backspacing over the !
at the end of the ex command, but is there a more 'official' way to do
this?

Thanks,

Ephraim

Andy Wokula

unread,
Sep 28, 2008, 10:40:28 AM9/28/08
to vim...@googlegroups.com
Efraim Yawitz schrieb:

No, there isn't.

But in your example, you know the number of lines you want to get in
your range, so you can type
3:
to get
:.,.+2

In general:
!2j has the form {operator}{motion}
:h operator

You can create a custom operator (and name it e.g. "g:") with
:h g@

Once it has been done here (from Jan 2008, see the whole discussion)
http://groups.google.com/group/vim_dev/msg/c6fb56645c188244

The details are somewhat tricky (if this reads better than ugly ...).

--
Andy

Efraim Yawitz

unread,
Sep 28, 2008, 11:02:47 AM9/28/08
to vim...@googlegroups.com
On Sun, Sep 28, 2008 at 5:40 PM, Andy Wokula <anw...@yahoo.de> wrote:

> But in your example, you know the number of lines you want to get in
> your range, so you can type
> 3:
> to get
> :.,.+2
>

That's pretty much what I was looking for. Where is it documented
that you can give a count to ':' ?

Efraim Yawitz

unread,
Sep 28, 2008, 11:17:14 AM9/28/08
to vim...@googlegroups.com
Never mind. I found it myself in cmdline.txt
Reply all
Reply to author
Forward
0 new messages