vscode-snippets

Pad selected lines to cursor position in VSCode

妖精的绣舞 提交于 2020-04-03 10:49:34
问题 In Visual Studio 2019, I can use Alt + Shift + (Arrow Keys) to multi-line edit the "virtual" whitespace then press any key to make all the lines padded with space to the selected column, I use this a lot to make initialization code easier to read. However, when I switched to Visual Studio Code, I could not find the equivalent. The closest thing I was able to find was Ctrl + Alt + (Arrow Keys) . This is not quite what I need since it only places each line cursor at the end instead of the

Pad selected lines to cursor position in VSCode

橙三吉。 提交于 2020-04-03 10:45:47
问题 In Visual Studio 2019, I can use Alt + Shift + (Arrow Keys) to multi-line edit the "virtual" whitespace then press any key to make all the lines padded with space to the selected column, I use this a lot to make initialization code easier to read. However, when I switched to Visual Studio Code, I could not find the equivalent. The closest thing I was able to find was Ctrl + Alt + (Arrow Keys) . This is not quite what I need since it only places each line cursor at the end instead of the

VS Code: How to convert snippet placeholder to uppercase or lowercase?

对着背影说爱祢 提交于 2019-12-20 23:31:28
问题 In VS Code, the docs for creating user defined snippets mentions some Grammar which includes options for /upcase , /downcase , and /capitalize , but I can't figure out how to use it. I'm using the latest version of VS Code: Version 1.25.0 on Mac. It seems like this snippet should convert the value of the placeholder to uppercase and to lowercase after typing it and hitting tab, but it doesn’t: "test": { "prefix": "test", "body": "${1} -> ${1:/upcase} ${1:/downcase}" }, Flow and Expected

How to pad out line to certain length using regex replace and snippets

蹲街弑〆低调 提交于 2019-12-18 09:57:23
问题 // My Section ----------------------------------------------------------------- The above is the desired result. Imagine this scenario // ---------------------------------------------------------------------------- // firebase // ---------------------------------------------------------------------------- // utils It is possible to trim lines to a certain length using for example this regex /(^.{20}).*$/$1/ , which will give // ----------------- // firebase // ----------------- // utils But

Is there a way to trim a TM_FILENAME beyond using TM_FILENAME_BASE?

别等时光非礼了梦想. 提交于 2019-12-11 18:46:38
问题 I am trying to create a snippet for a redux container file that takes an import of some react file of the same base name. TM_FILENAME_BASE works great for removing the .js from the file name but in this case, my component file's extension is fun-thing.component.js and the container will follow suit with an extension that is fun-thing.container.js. The Regex I am using to select everything before the first period is ^([^.]+) "Redux Container": { "prefix": "rc", "body": [ "// @flow", "import {

Make a vscode snippet that can use a variable number of arguments

萝らか妹 提交于 2019-12-11 15:34:10
问题 I am new to VSCode. Thinking about code snippets, I looked around for a way to kind of script inside the snippet. I mean to do more than just fill or transform a variable. For example... This is a simple snippet. I am going to type rci for the class initializer. When I enter the method arguments I would like the assignment and documentation + some other things to happen. rci<tab> and then def initialize(a, b) ) to result in something like this... attr_reader :a attr_reader :b # @param a [...]

vscode if/else conditions in user defined snippet

徘徊边缘 提交于 2019-12-11 08:49:22
问题 Looking at the vscode documentation for user defined snippets, it would appear that using the regex transform, you can do if/else conditions. However, I can't seem to find any examples of this and I'm struggling to understand the correct syntax based on the BNF alone. Can someone explain the syntax for this? For example, Lets say I have a snippet like this: "body": [ "let color = '${1|white,black|}';", "let hex = '${???}';" ] If color==white , I want hex to output #fff , otherwise if black

VSCode snippet: add variable number of objects to a class constructor

会有一股神秘感。 提交于 2019-12-10 11:57:20
问题 I am trying to create a simple snippet that allows me to create JS Constructors. So far, what I have is "class constructor": { "prefix": "class", "body": [ "class ${1:ClassName} {", "\t\tconstructor({${2:thisName}: ${2}}) {", "\t\t\tthis.${2} = ${2}", "\t}", "}" ], "description": "class constructor template" }, This works as expected, but what I am trying to see if it is possible to add multiple entries which also creates a new line for this , but in this case, the snippet runs its course

VS Code: How to convert snippet placeholder from camelCase to SCREAMING_SNAKE_CASE?

夙愿已清 提交于 2019-11-30 19:16:58
I'd like to create a VS Code snippet for creating redux reducers. I would like to have a snippet with placeholder that expects camelCase and then transform a matching placeholder to SCREAMING_SNAKE_CASE. Here's my attempted snippet, which is not working: "test": { "prefix": "test", "body": "${1} -> ${1/([a-zA-Z])(?=[A-Z])/${1:/upcase}_/g}" }, Which produces a non-desired result: changeNetworkStatus -> changE_NetworK_Status Desired Flow type test (name of snippet) hit tab to load the snippet. type changeNetworkStatus to result in: changeNetworkStatus -> changeNetworkStatus hit tab to get

VS Code: How to convert snippet placeholder from camelCase to SCREAMING_SNAKE_CASE?

自作多情 提交于 2019-11-30 02:54:47
问题 I'd like to create a VS Code snippet for creating redux reducers. I would like to have a snippet with placeholder that expects camelCase and then transform a matching placeholder to SCREAMING_SNAKE_CASE. Here's my attempted snippet, which is not working: "test": { "prefix": "test", "body": "${1} -> ${1/([a-zA-Z])(?=[A-Z])/${1:/upcase}_/g}" }, Which produces a non-desired result: changeNetworkStatus -> changE_NetworK_Status Desired Flow type test (name of snippet) hit tab to load the snippet.