3

I would like to create a mapping for emailing a link to the page displayed in the current tab:

:map ,m :! mail -s "here's a link" email@example.com<cr><current-url><C-d>

I am trying to figure out how to replace with the url of the page currently displayed in the tab.

If you are familiar with vim, it would be the equivalent of %.

Jon Lorusso
  • 133
  • 1
  • 5

1 Answers1

6

Use :execute, where you can use the Javascript API:

:map ,m :execute '!echo ' + buffer.URL + ' | mail -s "Subject" mail@example.com'

Or use a javascript mapping, like:

javascript <<EOF
function MyFoo() {
    alert(buffer.URL.host);
}
EOF
map <Leader>f -js MyFoo();

See https://github.com/blueyed/dotfiles/blob/master/pentadactylrc#L212 for a more sophisticated function to setup the editor based on host names.

blueyed
  • 1,241