Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard shortcut in VSCode for Markdown links?

from other text editors I'm used to adding Markdown links by

  1. selecting the word I want to be linked,
  2. pressing cmd-K on my Mac's / iPad Pro's keyboard, which puts square brackets around the marked word, appends a pair of normal parenthesis () and places the cursor right in beetween those two parenthesis so that I can
  3. just paste the URL I have in my clipboard into the right place by pressing cmd-V.

So, select -> cmd-K -> cmd-V is a nice and short sequence for adding links in a Markdown document and cmd-K has become some kind of pseudo standard for adding links in several writing apps.

However, in VSCode that's not possible. But I'd love to make it possible. Any ideas? cmd-K is (hard-wired?) bound to listen for a next key press. But it doesn't have to be cmd-K. I can learn another keystroke. But I need to be able to put additional text (square brackets and parenthesis) into the text and move the cursor to the right position. How's that done?

Thanks so much!

like image 809
metawops Avatar asked Nov 25 '19 11:11

metawops


People also ask

How do you hyperlink in markdown?

Markdown syntax for a hyperlink is square brackets followed by parentheses. The square brackets hold the text, the parentheses hold the link.

How do I show markdown in VS Code?

Tip: You can also right-click on the editor Tab and select Open Preview (Ctrl+Shift+V) or use the Command Palette (Ctrl+Shift+P) to run the Markdown: Open Preview to the Side command (Ctrl+K V).

What is Ctrl Shift P in VS Code?

You can define a keyboard shortcut for any task. From the Command Palette (Ctrl+Shift+P), select Preferences: Open Keyboard Shortcuts File, bind the desired shortcut to the workbench.


1 Answers

This extension Markdown All In One looks like it does what you want in one step.

Paste link on selected text

paste link demo

Just select your link and hit Ctrl+V and it creates the link and inserts the clipboard link.

If for some reason you don't want to use this extension, it would be pretty easy to create a snippet to do what you want.

like image 137
Mark Avatar answered Sep 30 '22 13:09

Mark