no selection => [|]()
selection => [$selection](|)
where:
| marks the place the cursor should move to$selection is the content of the current selectionPS: I'm aware of the existence of "Paste link on selected text" (which is great! :+1:).
Still, I miss the functionality I'm proposing. Specially for the 1st case.
Thanks for the feedback.
This can be easily done by defining a user snippet (with
TM_SELECTED_TEXTvariable). Also see here.
--- _copied from https://github.com/yzhang-gh/vscode-markdown/issues/799#issuecomment-683359820_
FYI
@yzhang-gh Thank you very much for the information. :smile: :+1:
Here's what I came up with:
{
"key": "alt+l",
"command": "editor.action.insertSnippet",
"when": "editorLangId == 'markdown'",
"args": {
"snippet": "[$TM_SELECTED_TEXT]($0)"
}
}
It doesn't implement _exactly_ the behaviour I wanted. The "no selection" case changed from:
no selection => "[|]()"
to:
no selection => "[](|)"
I guess VSCode's snippet language is not that expressive. But... maybe this is good enough.
I guess it can be
{ "key": "alt+l", "command": "editor.action.insertSnippet", "when": "editorLangId == 'markdown'", "args": { "snippet": "[$TM_SELECTED_TEXT$1]($0)" } }
Ah, I see your point. But I think [$TM_SELECTED_TEXT$1]($0) is better.
What do you think about bundling this with your plugin?
Is it be possible?
Do you like the idea?
I prefer not to repeat what can be solved by VS Code itself. (The only benefit is we can save one tab keypress when the selection is not empty.)
Also, user settings now can be synced by VS Code so there should be no disadvantage of this (user snippets) solution.
What do you think about bundling this with your plugin?
What I meant by "this" is "this snippet". How about including it in the plug-in? Would this be possible? Some plug-ins install snippets.
Then other users wouldn't have to go through this whole "R&D" process you and I just did[1], and just benefit from the result.
[1] which was really cool, don't get me wrong. But packaging it so others can just benefit from the results is also cool. 馃槉
Well, thanks for the suggestion. But I don't think this feature is popular enough (for now). And choosing a (good) default keybinding is hard (#89).
Ok. Thanks again for all the information and help. 馃槉 :+1:
Most helpful comment
I guess it can beAh, I see your point. But I think
[$TM_SELECTED_TEXT$1]($0)is better.