4

I have vim-snippets installed (which, as I understand it, is basically built on top of ultisnips).

How do I add a snippet to markdown files (i.e., .md and .markdown files) such that if I type a // followed by a tab it converts it into a <!-- --> HTML comment?

1
  • Do you have ultisnips installed? But you should be able to add something to UltiSnips/markdown.snippets. Commented Sep 20, 2015 at 21:13

1 Answer 1

3

In fact vim-snippets is a sideplugin that provides general snippets for various programming languages thorugh plugins (like: UltiSnips, snipmate, ... ) that provide snippet support to vim. so you should first have Ultisnips and vim-snippets plugins installed at the same time. then to add your desired snippet add the following code to vim-snippets/UltiSnips/markdown.snippets file.

########################
# My Personal Snippets #
########################
snippet // "Comment"
<!-- ${1} -->
endsnippet

Of course vim-snippets is a general system and has some policis for writing snippets and you may after a while want to update this plugin and your custom snippets ( your personal ones ) will be gone. so its wiser to define your personal snippets in your dot files. In this case just make a file named markdown.snippets in .vim/UltiSnips folder and add the same lines of code to that file. This way your vim-snippets plugin is intact and also you have your personal snippets managed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.