tags:

views:

363

answers:

3

The following in command mode (gvim)

:.,G!sort

results in

E464: Ambiguous use of user defined-command

:help E464
  Ambiguous use of user-defined command

There are two user-defined commands with a common name prefix, and you used
Command-line completion to execute one of them. |user-cmd-ambiguous|
Example: >
    :command MyCommand1 echo "one"
    :command MyCommand2 echo "two"
    :MyCommand

  Not an editor command

I have stared at this for a little while can someone throw a bone my way or offer a way to do this without resorting to visual mode?

+7  A: 
Chris Jester-Young
DO you see anything logically wrong with my attempt?
ojblass
See John Kugelman's answer. :-)
Chris Jester-Young
Riddle me this Batman: how does one do "!{motion}{filter}"? None of these work: !Gsort ... !G,sort ... !G sort
John Kugelman
!Gsort does work in nvi. What does vim say?
Chris Jester-Young
Wait, it works in vim too! :-P (At least my version thereof.)
Chris Jester-Young
Not in vim 7.2.22 on my Mac, apparently. I get "Gsort: command not found" from the shell. OK, at least I'm not a dunce!
John Kugelman
I think the motion has to come before the ! and that was what I was intending to do. But I was mixing up motions and ranges. :!Gsort results in Gsort not found (as expected by me). :G!sort leads to the ambigous thing above.
ojblass
@Chris what version of vim are you using?
ojblass
@John: If you're doing the !motion thing, don't type the colon! You have to put the ! in vi mode, not ex mode! (The latter expects a range.)
Chris Jester-Young
@ojblass: I'm using vim 7.2 that comes with Ubuntu 9.04.
Chris Jester-Young
I am on the same but here the help about shows version 7.2.79
ojblass
+5  A: 

G is a motion, not a range specifier. See :help range.

John Kugelman
Thank you very much!
ojblass
A: 
" vim has internal sort
:.,$sort

"if has numbers use
:.,$sort n

"to delete duplicated lines
:.,$sort u

" read :h sort