On Tue, 3 Oct 2006 at 10:30am, A.J.Mechelynck wrote:

> Nikolai Weibull wrote:
> > On 10/1/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
> >>
> >> Nikolai Weibull wrote:
> >>
> >> > One thing that really annoys me with Vim is the limits it emposes on
> >> > what names are legal for user-defined functions and commands.  I know
> >> > the reason for these restrictions, but I don't think they make much
> >> > sense, especially so for user-defined commands.  I realize that
> >> > overriding :quit does have its implications, but done carefully, this
> >> > does allow for some interesting effects.
> >> >
> >> > So, why not lift the restrictions on valid names for user-defined
> >> > functions and commands?
> >> >
> >> > That is, give me good reasons for why they should be maintained and
> >> > I'll drop this request.
> >>
> >> Predictability.
> >
> > As in what?  That :quit always works as documented?  Sure, that's
> > great, but if that's the problem, the restriction should be limited to
> > commands already defined.  And what happens when more commands are
> > added?  Hell, then they'll break the user-defined commands with the
> > same name.  Big deal; that's life, you'll get over it - everyone does,
> > eventually.
> >
> > I really don't see the big difference between user-defined commands
> > clashing with built-in commands and user-defined commands clashing
> > with each other.  It'll happen; unless you start adding prefixes or
> > namespaces or some other way of separating your commands.  But then
> > you lose out on simplicity.  You don't want to type :NOWCommand (given
> > that "NOW" is "my" prefix), and I don't want to type :Command; I want
> > to type :command.
> >
> > Sure, it only saves my fingers from giving up on me for so long, but
> > every little bit helps.
> >
> > I guess my problem is that I want - and I've always wanted - the
> > flexibility of Emacs coupled with the simplicity and efficiency of
> > Vim's command set and modes.  I guess that's why I nitpick at things
> > such as this.
> >
> >  nikolai
> >
>
>       :command -bar Command  ...
>       :cabbrev command Command
>
> and then you'll wonder why you can't define a new user-command but it's your
> funeral.
>
> It's still not perfect though; the cabbrev will be expanded even if it's not
> at the start (but that may be not-so-bad if you use ":verbose command",
> ":vertical command", etc.)
>
>
> Best regards,
> Tony.

You can use the Vim7 <expr> abbreviation in combination of getcmdpos()
and getcmdtype() to make this a lot more reliable, and avoid expanding
everywhere. I have created the cmdalias.vim plugin
(http://www.vim.org/script.php?script_id=745) just to address this
problem (as it bothered me as well). The only case this breaks is the
debug mode because of a bug in Vim (the expression itself is executed in
the debug mode).

Another oddity in using this approach is the history. If you execute:

:command

what will end up getting stored in the history is:

:Command

which means you have to remember to use the righ case while retrieving
the last command (:com<Up> will not work).

-- 
HTH,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to