-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Should markdown url smart paste be disabled if the user hasn't made a selection? #188871
Comments
I agree we should think about selection + smart paste. It boils down to - how often do users want to have a URL in markdown as a full https link? If the answer is > 30% then I think we should only have smart paste on selection. As for disabling smart paste if in a word - I still think this makes sense. I like that we have disable smart paste if in a link - thanks for that! |
|
This also keeps tripping me up. I assumed I had chosen a bad configuration, but it sounds like this actually can't be configured easily. Both "always" and "smart" will try to create linked text, making it annoying to paste a URL directly. I also agree that GitHub behaviour is much more practical, and it would also be nice for the behaviour match for those of us who spend most of our programming time in VS Code and GitHub. If anyone has a combination of shortcuts and settings that matches GitHub, I'd love to know. Else, I'd love to learn a way to set ⇧⌘V to paste the link without formatting. |
Okay, I figured out how to do this: // keybindings.json
[
// Disable existing ⇧⌘V shortcuts — modify to taste
{
"key": "shift+cmd+v",
"command": "-notebook.cell.pasteAbove",
"when": "notebookEditorFocused && !inputFocus"
},
{
"key": "shift+cmd+v",
"command": "-markdown.showPreview",
"when": "!notebookEditorFocused && editorLangId == 'markdown'"
},
// Enable ⌥⌘V for plain text paste
{
"key": "shift+cmd+v",
"command": "editor.action.pasteAs",
"args": {
"id": "text"
},
"when": "editorLangId == 'markdown'"
}
] In theory it should be possible to use [
{
"key": "shift+v",
"command": "editor.action.pasteAs",
"args": {
"id": "text"
},
"when": "!editorHasSelection && editorLangId == 'markdown'"
}
] The next approach would be to trigger "smart" paste only when |
Okay, I think I've got it: // keybindings.json
[
{
"key": "cmd+v",
"command": "editor.action.pasteAs",
"args": {
"id": "text"
},
"when": "!editorHasSelection && editorLangId == 'markdown'"
},
{
"key": "cmd+v",
"command": "editor.action.clipboardPasteAction",
"args": {},
"when": "editorHasSelection || editorLangId != 'markdown'"
},
{
"key": "cmd+v",
"command": "-editor.action.clipboardPasteAction"
}
] This also seems to work, but I'm not 100% confident about the priority of conflicting conditions: // keybindings.json
[
{
"key": "cmd+v",
"command": "editor.action.pasteAs",
"args": {
"id": "text"
},
"when": "!editorHasSelection && editorLangId == 'markdown'"
},
{
"key": "cmd+v",
"command": "-editor.action.clipboardPasteAction",
"when": "!editorHasSelection && editorLangId == 'markdown'"
}
] But this took over half an hour of experimentation + digging through the VS Code source code and documentation. It also doesn't take into account:
I presume changing the default behaviour would involve adding an early vscode/extensions/markdown-language-features/src/languageFeatures/copyFiles/pasteUrlProvider.ts Line 18 in 11bfd76
|
Here's a try for a version that takes these into account: // keybindings.json
[
{
"key": "cmd+v",
"command": "editor.action.pasteAs",
"args": {
"id": "text"
},
"when": "inputFocus && !editorHasSelection && editorLangId == 'markdown'"
},
{
"key": "cmd+v",
"command": "-editor.action.clipboardPasteAction",
"when": "inputFocus && !editorHasSelection && editorLangId == 'markdown'"
},
{
"key": "shift-cmd+v",
"command": "editor.action.pasteAs",
"args": {
"id": "text"
},
"when": "inputFocus && editorHasSelection"
}
] It avoids clobbering the ⇧⌘V shortcut for
|
Can we rename the current I'm using Markdown to write notes, and reference links to other websites are often used. With the current |
This is now the default. You can then use the paste widget to switch after the paste has taken place @Alecton4 Good idea. I think I'll add a new option called |
http://example.com
Bug
Currently this inserts a markdown link. However this is different from what GitHub does. Github seems to only create a link if you have a selection
We should at least think about:
The text was updated successfully, but these errors were encountered: