On 09/08/09 05:26, googler wrote:
>
>
>
> On Aug 4, 2:21 pm, googler<[email protected]>  wrote:
>> I want to define a command using ":command" and want to specify range
>> as part of the command. For example, if my command is called MyCmd, I
>> can run something like this - :100,150 MyCmd. Now, I see that there
>> are some options regarding the default range vim chooses in the case I
>> do not specify one. It can be the current line or the entire file.
>> However, my requirement is a little different. In some cases, the user
>> may not specify a range with this command. In those cases, I want the
>> called function to know that no range has been passed and it will work
>> a little differently in those cases (for example, it will choose the
>> last highlighted region as the range). Can this be done? Thanks.
>
> I didn't get any reply to this, so I just wanted to follow up in case
> it wasn't noticed earlier. Thanks :)

In Vim, the help says it all. So, :help :command-range gives the 
following possibilities:

* both -range and -count omitted: a range can never be used
* -range : range allowed, default is current line (as in :s)
* -range=% : range allowed, default is whole file (as in :w)
* -range=N : count allowed in line number position, default N
* -count=N : count allowed either in line number position or as first 
argument, defaults to N

So, IIUC, the answer is: "you can't" have a command where all three of 
the following are valid and act in three different ways:

        :MyUserCommand
        :.,.MyUserCommand
        :1,$MyUserCommand

Regards,
Tony.
-- 
 From the "Guiness Book of World Records", 1973:

Certain passages in several laws have always defied interpretation and
the most inexplicable must be a matter of opinion.  A judge of the
Court of Session of Scotland has sent the editors of this book his
candidate which reads, "In the Nuts (unground), (other than ground
nuts) Order, the expression nuts shall have reference to such nuts,
other than ground nuts, as would but for this amending Order not
qualify as nuts (unground)(other than ground nuts) by reason of their
being nuts (unground)."

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to