Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to copy link with title in markdown format? #906

Closed
ooker777 opened this issue Jan 4, 2018 · 9 comments
Closed

How to copy link with title in markdown format? #906

ooker777 opened this issue Jan 4, 2018 · 9 comments

Comments

@ooker777
Copy link

ooker777 commented Jan 4, 2018

I'd like to have [title](url) be copied instead of bare url when yy is pressed. Any thoughts?

Edit: I have asked this on Super User

@lydell
Copy link
Collaborator

lydell commented Jan 4, 2018

You can steal this custom command:

https://github.com/autopp/vimfx-config/blob/1629d79e09ae6c464f68c0aeb6b13e79f7210860/config.js#L3-L13

vimfx.addCommand({
  name: 'copy_markdown',
  description: 'Copy as markdown link',
  category: 'location',
}, ({vim}) => {
  let url = vim.window.gBrowser.selectedBrowser.currentURI.spec
  let title = vim.window.gBrowser.selectedBrowser.contentTitle
  let fmt = "["+title+"]("+url+")"
  gClipboardHelper.copyString(fmt)
  vim.notify("Copied String: "+ fmt)
});

@lydell lydell closed this as completed Jan 4, 2018
@ooker777
Copy link
Author

ooker777 commented Jan 4, 2018

It doesn't change how yy functions, nor show in the location category. I've followed the tutorial.
I notice it creates extensions.VimFx.custom.mode.normal.copy_markdown in about:config, but changing its value doesn't work.

Testing on this very page:

https://github.com/akhodakivskiy/VimFx/issues/906#event-1409806435

I've edited the Custom Commands.

@lydell
Copy link
Collaborator

lydell commented Jan 4, 2018

The tutorial you link to says:

If you add custom commands, remember to add shortcuts to them!

And the above link goes to:

Note that you have to give the new command a shortcut in VimFx’s options page in the Add-ons Manager or set one using vimfx.set(...) to able to use the new command.

vimfx.addCommand({
  name: 'hello',
  description: 'Log Hello World',
}, () => {
  console.log('Hello World!')
})
// Optional:
vimfx.set('custom.mode.normal.hello', 'gö')

Is that what you're looking for?

@ooker777
Copy link
Author

ooker777 commented Jan 5, 2018

The new command doesn't appear in the panel until I restart Firefox. It works, thanks.

@ooker777
Copy link
Author

ooker777 commented Jan 5, 2018

ugh, this does not work again, even though the command has been shown in the panel. yy works fine, but Firefox search for u when I press yu.


I've also already added this at the end of the script

vimfx.set('custom.mode.normal.copy_markdown', 'yu')

@lydell
Copy link
Collaborator

lydell commented Jan 6, 2018

Ahw, sad to hear it's working so badly for you :( I hope you'll figure it out.

@ooker777
Copy link
Author

I really like to have this worked. Do you know where should I investigate this?

@lydell
Copy link
Collaborator

lydell commented Jan 15, 2018

If I were you I wouldn't spend time on this. VimFx is dead.

@ooker777
Copy link
Author

ooker777 commented Jan 17, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants