This extension for Visual Studio Code allows you to save and insert code templates for various programming languages. It provides two commands: extension.saveCodeTemplate and extension.insertCodeTemplate.
The main extension code (extensions.ts) is located in the following directory: /src/extension.ts
The extension.saveCodeTemplate command allows you to save a code template for a specific programming language, and it can also be invoked using the shortcut key combination - Command+Shift+K (macOS) or Ctrl+Shift+K (Windows).
The user needs to enter the template name, and the template will be saved in the global state using a key consisting of the category and template name. For example, if the template is named "Hello World" for the JavaScript language, it will be saved as "javascript_hello_world".
The extension.insertCodeTemplate command allows you to insert a saved code template, and it can also be invoked using the shortcut key combination - Command+Shift+I (macOS) or Ctrl+Shift+I (Windows). The user needs to enter the name of the template they want to insert, and the template will be inserted into the active text editor at the current cursor position.
The getCategoryForLanguage function uses a switch statement to determine the category for each supported programming language. Currently, the supported languages are C, C++, Python, PHP, Rust and JavaScript. For each language, the function returns the corresponding category, for example, "c_cpp" for C and C++. If the language is not supported, the function returns undefined.
Overall, this extension provides a simple way to save and use code templates for various programming languages in Visual Studio Code.
In the root directory of this repository, there is a .vsix file that needs to be installed in Visual Studio Code.
First, you need to open the Command Palette. This can be done using the following key combination - Command + Shift + P (macOS) or Ctrl + Shift + P (Windows). Type install from VSIX and select the .vsix file from the root directory of the repository.
Это расширение для Visual Studio Code позволяет сохранять и вставлять шаблоны кода для различных языков программирования. Оно предоставляет две команды: extension.saveCodeTemplate и extension.insertCodeTemplate.
Основной код расширения (extensions.ts), находиться в слеудющей директории /src/extension.ts
Команда extension.saveCodeTemplate позволяет сохранить шаблон кода для определенного языка программирования, так же можно вызвать ее с помощью горячих клавиш - Command+Shift+K (macOS) или Ctrl+Shift+K (Windows).
Пользователь должен ввести имя шаблона, и шаблон будет сохранен в глобальном состоянии с использованием ключа, состоящего из категории и имени шаблона. Например, если шаблон называется "Hello World" для языка JavaScript, он будет сохранен как "javascript_hello_world".
Команда extension.insertCodeTemplate позволяет вставить сохраненный шаблон кода, так же можно вызвать ее с помощью горячих клавиш - Command+Shift+I (macOS) или Ctrl+Shift+I (Windows). Пользователь должен ввести имя шаблона, который он хочет вставить, и шаблон будет вставлен в активный текстовый редактор в текущей строке курсора.
В функции getCategoryForLanguage используется оператор switch для определения категории для каждого поддерживаемого языка программирования. В настоящее время поддерживаются языки C, C++, Python, PHP, Rust и JavaScript. Для каждого языка программа возвращает соответствующую категорию, например, "c_cpp" для C и C++. Если язык не поддерживается, функция вернет undefined.
В целом, это расширение предоставляет простой способ сохранения и использования шаблонов кода для различных языков программирования в Visual Studio Code.
В корневой директории данного репоизтория есть файл .vsix, его нужно установить в Visual Studio Code.
Сначала вам необходимо открыть Command Palette. Это можно сделать через следующую комбинацию - Command + Shift + P (macOS) или Ctrl + Shift + P (Windows). Вписать install from VSIX и выбрать .vsix файл из корневой директории репозитория.