1995eaton / chromium-vim

Vim bindings for Google Chrome.
https://chrome.google.com/webstore/detail/cvim/ihlenndgcmojhcghmfjfneahoeklbjjh
MIT License
2.25k stars 325 forks source link

Enhancement: Support arguments for the command `:command` #485

Open dumblob opened 8 years ago

dumblob commented 8 years ago

I was trying to mimic the following Pentadactyl's configuration:

map c :prefix-
command -nargs=* prefix-y   tabopen http://m.youtube.com/results?q=<args>

Which allows the following procedure:

  1. press c (results in command bar appearing with the content :prefix- and text cursor positioned after the last character, i.e. -)
  2. press y (results in y being added after the dash, i.e. the full command bar content is :prefix-y)
  3. press <Space> (results in `being added aftery, i.e. the full command bar content is:prefix-y `)
  4. type my favourite video (the full command bar content is :prefix-y my favourite video)
  5. press <CR> (results in all the arguments my favorite video being encoded according to URI, i.e. to my%20favourite%20video and then <args> from http://m.youtube.com/results?q=<args> being replaced with the encoded string my%20favourite%20video and first then the whole resulting command tabopen http://m.youtube.com/results?q=my%20favourite%20video is executed)

In cVim the command :command does not support any arguments, so I'm proposing adding e.g. the above-mentioned argument -nargs.

dumblob commented 7 years ago

@1995eaton would this be now easier to implement with the new PEG parser landing?