本文介绍了如何在VS Code中为用户片段编写多行描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图在VS Code中为pascal创建自己的用户代码段。 正常工作,我写的多行描述已正确显示。 但是过了一段时间(例如一个月),多行描述不再起作用。 问题可能是多行描述的代码,因为只有一行的描述仍然有效并且显示正确。 但是多行描述无法正确显示,而是被{0}代替了我写的描述。I tried to create my own user snippet for pascal in VS Code.It worked fine and the multi-line descriptions I wrote were displayedcorrectly.But after a while, like a month, the descriptions with multiple lines aren't working anymore.The problem may be the code for the multi-line descriptions because descriptions with only one row still works and displays correct.However the multi-line descriptions aren't displayed correctly and get replaced with a {0} instead of the description I wrote.将显示以下行描述:不是我的描述,而是{0},我不知道为什么,因为它在一个月前工作正常。Instead of my description there is a {0} and I don't know why because it worked fine a month ago.这是我使用的代码:{ "SetValue":{ "prefix": "SetValue", "body": "SetValue(${1:val:Integer}, ${2:id:Integer});", "description": [ "Parameter:\r", " val...desc\r", " id....desc\r", "\r", "result:\r", " 0 : false desc\r", " 1 : true desc\r" ] }}我希望我已经表达了自己的理解,您可能会对此有所帮助问题。谢谢您的关注!I hope I have expressed myself understandably and you may can help me with this problem. Thanks for your attention!推荐答案我无法解释为什么更改了它,但它似乎只接受一个字符串(而不接受字符串数组)。但是您仍然可以构建一个字符串-有点难看,但是它可以工作:I can't explain why it changed but it appears to accept only one string (and not an array of strings). But you can still build up one string - a little ugly but it works:"description": "Parameter:\rval...desc\r id....desc\r\rresult:\r 0 : false desc\r 1 : true desc\r"现在,它将按您的期望显示在建议面板中。Now it will display in the suggestions panel as you expect. 编辑:v1.31修复了此问题,因此您可以使用字符串数组而不是一个长字符串。 片段说明Edit: v1.31 fixed this so you can use an array of strings rather than one long string. Snippet descriptions 在编写带有长描述的代码片段时,过去您被迫写一个长字符串。没有为身体使用数组的支持。现在,这种情况已经改变,可以使用字符串数组编写长的描述。 When authoring snippets with long descriptions, in the past you were forced to write a long single string. There was no support for using an array as you could for body. This has now changed and long descriptions can be written using string arrays.{ "prefix": "happy", "body": "#Happy Coding!", "description": [ "First Line", "Second Line", "Third Line" ]} 这篇关于如何在VS Code中为用户片段编写多行描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-29 17:21