intro
Snippets in Visual Studio Code
Snippets, no contexto da programação e do desenvolvimento web, são pequenos blocos de código reutilizáveis. Eles servem como atalhos ou modelos que podem ser inseridos e adaptados rapidamente para realizar uma tarefa específica.
Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements.
In Visual Studio Code, snippets appear in IntelliSense (Ctrl+Space) mixed with other suggestions, as well as in a dedicated snippet picker (Insert Snippet in the Command Palette). There is also support for tab-completion: Enable it with "editor.tabCompletion": "on", type a snippet prefix (trigger text), and press Tab to insert a snippet.
The snippet syntax follows the TextMate snippet syntax with the exceptions of 'interpolated shell code' and the use of \u; both are not supported.
https://code.visualstudio.com/docs/editing/userdefinedsnippets
Highlighting with comments
You can use comments with highlight-next-line
, highlight-start
, and highlight-end
to select which lines are highlighted.
function HighlightSomeText(highlight) {
if (highlight) {
return "This text is highlighted!";
}
return "Nothing highlighted";
}
function HighlightMoreText(highlight) {
if (highlight) {
return "This range is highlighted!";
}
return "Nothing highlighted";
}
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
// Place your code HERE!
}
/* USER CODE END 3 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
// Place your code HERE!
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
// Place your code HERE!
}
/* USER CODE END 3 */