Reputation: 849
Vim's Utl plugin offers a convenient way for doing web queries from within the editor. When called directly from the command line, a dictionary lookup can be done like this:
:Utl ol http://dict.leo.org/?search=my+search+term
What's the correct way for defining a custom command with the same purpose (my+search+term
being user input)? I can't seem to get <f-args>
right with this one:
command -nargs=1 SearchLeo :exe ":Utl ol http://dict.leo.org/?search=" . expand("<f-args>")
What's the correct way of defining function arguments here? Or should I turn this into a more complete function? Thanks!
Upvotes: 3
Views: 1926
Reputation: 172540
expand()
here; it's just for expanding globs (like *.txt
) or the special variables like %
for the current file.<f-args>
(<q-args>
would be slightly more correct, though it only matters with a variable number of arguments), once literally.Use this:
command -nargs=1 SearchLeo :exe ":Utl ol http://dict.leo.org/?search=" . <q-args>
Upvotes: 4