How to add links with a keyboard shortcut in Sublime Text

Last week, I wrote about my Sublime Text setup.
I write in markdown a lot. And one thing that’s been missing for me from Sublime is the ability to add a link to my markdown files using the command + K keyboard shortcut (or control + K for my Windows folks).
Last week, I found this solution comes from devcarlos over on the Sublime Text forums, and wanted to share how it works for archive purposes.


This content originally appeared on Go Make Things and was authored by Go Make Things

Last week, I wrote about my Sublime Text setup.

I write in markdown a lot. And one thing that’s been missing for me from Sublime is the ability to add a link to my markdown files using the command + K keyboard shortcut (or control + K for my Windows folks).

Last week, I found this solution comes from devcarlos over on the Sublime Text forums, and wanted to share how it works for archive purposes.

The Overview

It involves two parts…

  1. Create a new Snippet that wraps selected text in a link.
  2. Map a keyboard shortcut to the snippet.

Step 1. Create a snippet

To create a snippet in Sublime Text, select Tools > Developer > New Snippet... from the navigation menu.

The original snippet from devcarlos adds a proper link element with href, like this…

<snippet>
	<content><![CDATA[
<a href="${1}">${SELECTION}</a>
]]></content>
</snippet>

Because I use this exclusively in markdown, I chose to output a markdown link instead…

<snippet>
	<content><![CDATA[
[${SELECTION}](${1})
]]></content>
</snippet>

Save the file to the snippets directory inside the User directory, and give it the name markdown_link.sublime-snippet.

Step 2. Map the keyboard shortcut

Select Sublime Text > Settings... > Key Bindings from the navigation menu.

In the user bindings settings in the panel on the right, copy/paste the following JSON property…

{ "keys": ["super+k"], "command": "insert_snippet", "args": {"name": "Packages/User/link.sublime-snippet"} },

The super key binds to command on macOS and control on Windows, without having to specify different things for different operating systems.

When you’re done, save the file and close it.

Using it

In your markdown files, you can press command+k or control+k to generate a []().

If you highlight some text, then press the keys, the selected text gets wrapped in the square brackets automatically, like this…

[your selected text]()

I apparently could have done this years, and wish I had!

Like this? A Lean Web Club membership is the best way to support my work and help me create more free content.


This content originally appeared on Go Make Things and was authored by Go Make Things


Print Share Comment Cite Upload Translate Updates
APA

Go Make Things | Sciencx (2025-04-07T14:30:00+00:00) How to add links with a keyboard shortcut in Sublime Text. Retrieved from https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/

MLA
" » How to add links with a keyboard shortcut in Sublime Text." Go Make Things | Sciencx - Monday April 7, 2025, https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/
HARVARD
Go Make Things | Sciencx Monday April 7, 2025 » How to add links with a keyboard shortcut in Sublime Text., viewed ,<https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/>
VANCOUVER
Go Make Things | Sciencx - » How to add links with a keyboard shortcut in Sublime Text. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/
CHICAGO
" » How to add links with a keyboard shortcut in Sublime Text." Go Make Things | Sciencx - Accessed . https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/
IEEE
" » How to add links with a keyboard shortcut in Sublime Text." Go Make Things | Sciencx [Online]. Available: https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/. [Accessed: ]
rf:citation
» How to add links with a keyboard shortcut in Sublime Text | Go Make Things | Sciencx | https://www.scien.cx/2025/04/07/how-to-add-links-with-a-keyboard-shortcut-in-sublime-text/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.