defining an alias
The simplest way would be to give the command an alias and map the keybinding to invoke that alias.
command! via :execute ':open http://via.hypothes.is/' + buffer.URL
map -b <C-x><C-V> :via
You can then execute the command either with the keybinding, or on the command line via its alias via
.
executing the command immediately
That said, do you actually need the command to print out on the command line and wait for you to hit Enter? A preferable solution would be to just have the command execute immediately when you execute the keybinding. You can do that by either:
adding <CR>
to the end of the command you execute
map <C-x><C-v> :via<CR>
(this solution is portable to Vimperator); or
using the -ex
option to the map
command.
map <C-x><C-v> -ex via
executing command and printing a message
If for some reason you don't want an actual alias, but just want the command to execute while printing "via" in the echo area, you could use a binding like this:
map <C-x><C-V> -js
\ dactyl.open('http://via.hypothes.is/' + buffer.URL);
\ commandline.echo('via',commandline.HL_INFOMSG);
\ setTimeout(function(){ commandline.echo('', commandline.HL_INFOMSG); }, 500);
The 500
at the end is the delay (in milliseconds) before the message disappears. If you want it the message to stay until you enter a new command or change tabs, just remove the last line entirely.