3

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?

kjones
  • 1,339
  • 1
  • 13
  • 28
George
  • 6,927
  • 4
  • 34
  • 67
  • Do you have ultisnips installed? But you should be able to add something to UltiSnips/markdown.snippets. – FDinoff Sep 20 '15 at 21:13

1 Answers1

2

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.

dNitro
  • 5,145
  • 2
  • 20
  • 45