Cover Photo by Derick Anies on Unsplash
My First Real VSCode Extension
In my post where I talk about starting the #100DaysOfCode challenge, I mentioned one of the potential things I'd work on would be an extension for Visual Studio Code that would help me with inserting links into my Markdown files. This is particularly useful when writing posts such as this one where I do all the writing in a Markdown file on my machine and then copy/paste the content to dev.to or any other site I'm posting it to.
This is something I found particularly annoying to do, considering how simple and repetitive the process is:
- Select the text to turn into a link.
- Add the
[brackets around it.
- Add a [x + 1] reference where x is number of the last link I added to the post.
- Add the reference to the bottom of the file with the link next to it.
While not overly difficult, if you've ever automated/simplified a mundane task then you know the feeling I'm talking about.
Which leads me to today, where I've actually posted the code online in a GitHub repo. So far, the extension has nothing more than an
extension.insertLink command that will surround your selected text with brackets and add a
 reference to the end of it. Nothing fancy to say the least 😅 However, it's a good start as far as I can tell, since I've got the basis for making edits to the currently selected text, and I had no idea how to do that when starting this.
So far, the work I've managed to complete was largely thanks to the yo generator for Visual Studio Code extensions, the MDTools example, and the VSCode API documentation. So, a massive thank you to those who took part in those projects.
That's all I've got for today, and I'll be sure to post more updates as I get further along 😊
Latest comments (5)
It might be worth adding image support too, as it's the same syntax 🙂
OOOOO GOOD IDEA! The only difference would be the exclamation mark prefix. Once I get the link insertion done I'll have to add an image ability.
Thanks for the suggestion, Andrew! Hope your #100DaysOfCode challenge is going well 😊
Great plugin 👏
Instead of going down that path, you could just do
I did that for the longest time, the problem is when I reuse a link that's already been referenced, I could just reference that number.
Also, I simply like the lean look of the references and then the links at the bottom.
I just realized I never actually got around to adding this into the post itself, but I'm a sucker for naming projects and when I couldn't decide what to name this one, I translated insert from English to Esperanto and went with that 😅