On Pentadactyl: Use current tab's url in command I learned how to create a command that uses the current buffer's URL. I'm using this to rewrite the URL to use the hypothes.is "via hypothesis" proxy:

map -builtin <C-x><C-V> :execute ':open http://via.hypothes.is/' + buffer.URL

But when I press C-xC-V I see the whole command printed out in the "echo area":

:execute ':open http://via.hypothes.is/' + buffer.URL

Is there a way to make that print out more briefly, so that that whole command has an "alias" like :via?

1 Answer 1


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:

  1. adding <CR> to the end of the command you execute

    map <C-x><C-v> :via<CR>

    (this solution is portable to Vimperator); or

  2. 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.

  • @Joe Corneli: thanks for pointing out the missing keystrokes in the map commands of the second section. Not sure why your edit was rejected, but I've fixed the commands, anyway.
    – pyrocrasty
    Jan 19, 2016 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.