Open bobrocke opened 9 years ago
@bobrocke The nice thing about Atom is that you can add these commands yourself, through the init.coffee file. You don't really need to wait for a package to implement this (especially if it's something you need right now, and other users don't feel strongly about).
Here's what you might put in your init.coffee
to add such a command (warning: I haven't tested this much):
atom.commands.add 'atom-text-editor', 'markdown:paste-as-url', ->
return unless editor = atom.workspace.getActiveTextEditor()
selection = editor.getLastSelection()
cliptext = atom.clipboard.read()
selection.insertText("[#{selection.getText()}](#{cliptext})")
Now reload Atom and you should see a "Markdown: paste as url" command in the command palette. Once you have a command, you can add a keybinding for it.
Does that help?
Yes, in fact I'm working on my own personal utilities package and can put that in it while a broader solution is considered.
@izuzak the init.coffee link appears to not be working. Perhaps you wanted this?
@programster It was working at the time the comment was created -- you'll notice that the init.coffee file in the docs was updated and renamed since then, which broke the link. I've updated it in my comment so that it points to https://atom.io/docs/latest/hacking-atom-the-init-file, thanks for pointing it out.
@atom/feedback Do some other language-* packages add commands? I think this would be useful to add for GFM, but not sure if this package should be the place to do it or if a new package would be a better choice. I think it make sense to add it here, but wondering if you have any thoughts or know of examples?
I don't know of any language packages that add commands off the top of my head, no. But I don't think it would be that big of a deal. I think assigning keybindings might get challenging though.
Would it be possible for you to add a command that would replace the currently selected text with:
[$SelectedText$]($ClipboardContents$)
That would allow the user to copy a URL, select the desired anchor text, and then initiate the command.