AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Blogs
NAV
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 20.01.2020, 14:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
waldo: VSCode & Snippets
Источник: https://dynamicsuser.net/nav/b/waldo...scode-snippets
==============

I did apoll recently during one of my sessions – and I was surprised that about halfof the people don’t regularly use “snippets” in VSCode.. .

Well,some of you probably know that I’m a big fan of snippets. Whoever has joined one of my sessions of thelast couple of years where I was talking about VSCode, or was working withVSCode .. most probably, I was talking about, showing or using snippets.

Honestly,I can’t live my life in VSCode without snippets. It would be so much less efficient .. . VSCode wouldn’t be much more than a notepadthat is hooked up with Source Control in that case.

Back in2017, I even spent quite some time in my session on NAVTechDays about snippets. I’ll share the session at the end of thispost…

How to manually create snippets?

Iwould be able to explain you how to manually create snippets – but Iwon’t. Because it is actually alreadybeautifully explained on the documentation section of VSCode here: https://code.visualstudio.com/docs/e...efinedsnippets

Basically,user defined snippets …:
  • … is a json-file somewhere on your roaming profile
  • … have a specific syntax, which makes you give a description, a prefix, a body, … and for defining placeholders, including multi-cursor placeholders
  • … can use variables, like the filename, date or your clipboard, which make it possible to create very “generic” snippets.
All youneed to know is on the page mentioned above, and you’ll get going with snippetsin no time, I promise you!

My snippets

There ismore :-). I have been creating lots ofsnippets in myextension. I admit, I copiedMicrosoft’s snippets and improved them – but I also have created lots of newsnippets. Ones that I use a lot in termsof “design patterns”, but also for implementing code that I’m notused to, and don’t want to forget (like the assisted setup). If you install my “CRS AL LanguageExtension”, you’ll recognise my snippets with “waldo” in the suffix:

And yes,if you don’t want to work with my snippets, you can disable them by a simplesetting:

"CRS.DisableCRSSnippets": true(if youmight wonder, you can disable Microsoft’s snippets as well ;-)).

Tools that can help you to create snippets

Irecently was pointed to this tool: https://snippet-generator.app/ . When you are creating yourVSCode snippets, simply paste the text that you want to convert to a snippet tothis tool, and you immediately get it converted to a JSON representation for aVSCode snippet. I tremendously speeds upthe creating of a snippets from minutes to seconds ;-).

On theother hand, there is another tool that you can install in VSCode: the snippet-creator. It basically gives you a command that willconvert your selected text into a user-snippet of the language of your choice:

Whateveryou prefer – both work very nice :-).

Some questions I get a lot

Where are snippets stored?

The user-defined snippets that you create,  are stored here:
%USERPROFILE%\AppData\Roaming\Code\User\snippets.

The snippets that come from an extension, are stored here:
%USERPROFILE%\.vscode\extensions\\snippets

Can I disable snippets?

Well,no. You can’t in any decent way (that Iknow of) disable snippets. I know I wastalking about a setting in my extension, and yes, that’s a way, but it’s not adecent way ;-).

In fact,what I do in that extension, is simply rename the “snippets” folderto “snippets-disabled”. Thatway, the extension is not able to find the snippets, and won’t show themanymore. The downside of this is that itwill give errors in the background because it’s not able to find the snippetsanymore, like:

It’s notreally noticeable, but they are there… .

Can I change snippets?

Well, noagain. To be fair: you CAN change asnippet in the extension folder, but do know that when the extension isupdated, it basically is going to overwrite the snippets … and you lost yourmodification. So in my opinion, that’snot an option.

That wasit! Hope you’re into snippets and thisblogpost was completely useless. If not,at least I hope this got you triggered a bit ;-)! The only thing left for me is to share theNAVTechDays session I was talking about earlier:





Источник: https://dynamicsuser.net/nav/b/waldo...scode-snippets
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: AL Extension Pack for VSCode Blog bot NAV: Blogs 0 02.07.2019 10:11
waldo: AL with VSCode: IntelliSense Fix Blog bot NAV: Blogs 0 22.03.2018 10:11
waldo: AL with VSCode: ExportToNewSyntax Blog bot NAV: Blogs 0 07.08.2017 04:17
waldo: PowerShellGet & waldo’s PowerShell Modules Blog bot NAV: Blogs 0 17.01.2017 08:11
waldo: Microsoft Dynamics NAV 2017 – what’s really new? Blog bot NAV: Blogs 0 13.10.2016 05:22
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра
Комбинированный вид Комбинированный вид

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 02:22.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.