How to delete the content of the line in a vscode snippet - vscode-extensions

I've made a vscode extension that has a few snippets. For example this one:
"header4": {
"prefix": "header 4",
"body": [
"[header 4](Text='')"
],
"description": "Write a description for this snippet"
}
When I write he... it shows the snippet and I can click on it. Everything is fine it writes [header4]Text='').
My problem comes when I try to write [he... because I find the snippet but it writes [[header4]Text='')]. I don't want those brackets. I want to delete these brackets. Anyone know how to do that?
I tried to put variables but there is no variable that can help me. I tried to put the command bracketeer.removeBrackets but is not working either.
Any help?
Thank you

Related

Visual Studio Code shows a lot of errors in Cypress

I have a question with VSCode. I developed tests with Cypress and VS didn't show any problem. In fact, this tests are working right now. However, VS Code shows a lot of stranges errors today. For example 'describe' is not defined. (no-undef)' or 'Expected indentation of 4 spaces but found 8. (indent)' as you can see in the image.
I did not change the VS Code Settings. Why is it happening?
UPDATE: I think the problem is the new version of Cypress 7.5, but i have not found a solution yet
I tried to fix that with this steps:
File / Preferences / Settings then Text Editor (or just search for 'tab' in the search settings box)
Then remove the tick from the following settings:
Insert Spaces
Detect Indentation
But it didnt' work. FInally, I had to remove the JS6 VS Extensions and this errors dissapeared.
That was My problem too, The exact error was:
Expected indentation of 4 spaces but found 6. eslint(indent)
And to fix that, I just let ESLint knows that "I don't want it to take care of those indentations".
There're two approaches for that (base on the eslint docs):
1. Using configuration comment
Put the following comment at the very top of each file you want that indentation to be ignored:
/* eslint-disable indent */
2. Using configuration file
To disable the indentation rule for a group of files (ex. test.js or spec.js), use the following code snippet in the .eslintrc file:
{
/* Whatever's here */,
"overrides": [
{
"files": ["*-test.js","*.spec.js"],
"rules": {
"indent": "off"
}
}
]
}

How do I remap the default CTRL+f (find) in Visual Studio Code such that I can use CTRL+f as is typical in unix/linux?

In Visual Studio Code, Ctrl+f activates the Find widget. I use vscode on Windows 10 (ssh into 'nix) and separately on the Ubuntu 18.04 Linux distro (w/Gnome Shell), when using the integrated terminal. I expected Ctrl+f to step one character forward in the CLI, as is typical on many Linux terminals, within vscode. How do I accomplish this?
I'd additionally like to maintain the find functionality, if possible, though with a different binding.
Because my search in SO retrieved little, I'm posting the solution and references I found for the community.
After searching several links via Google, I found straightforward documentation to solve this problem at https://vscode.readthedocs.io/en/latest/editor/integrated-terminal/.
The solution, in summary:
Open up Preferences: Open Keyboard Shortcuts, e.g. Ctrl+Shift+p and typing keyboard and then enter or return.
Type Ctrl+f in the Keyboard Shortcuts search bar and find the "Terminal: Focus Find Widget" line. Mine looks like this:
Click the pencil icon to alter the keybinding. One available for me was Ctrl+Alt+f.
Note: the following is pasted from the docs for easy reference.
Or, in your keybindings.json change:
{ "key": "ctrl+f", "command": "-workbench.action.terminal.focusFindWidget",
"when": "terminalFocus" },
to something like this:
{ "key": "ctrl+alt+f", "command": "-workbench.action.terminal.focusFindWidget",
"when": "terminalFocus" },
I also had to add this to my settings.json to make it work (VSCode version 1.62.0):
"terminal.integrated.commandsToSkipShell": [
"-workbench.action.terminal.focusFind"
]
In my VSCode v1.58.2, it now looks like this:
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+alt+f",
"command": "workbench.action.terminal.focusFind",
"when": "terminalFindFocused && terminalProcessSupported || terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+f",
"command": "-workbench.action.terminal.focusFind",
"when": "terminalFindFocused && terminalProcessSupported || terminalFocus && terminalProcessSupported"
}
]

Short-cut key in VB.NET to take you to the end of the block [duplicate]

I know it's simple to do in C#, but what is the command to jump between If/End If marks in VB.Net like you can jump between braces in C#?
(C#-version of this Question: Go to Matching Brace in Visual Studio?)
If you're using Visual Studio 2010, you can use Ctrl+Shift+Up and Ctrl+Shift+Down to jump between highlighted references and keywords.
Since these are If blocks, the IDE will highlight the Then keyword as well, so just tap Up/Down twice in rapid succession. Up/down wraps, so if you really want to save a keypress, hit the key in the "wrong" direction to get where you want.
I've resorted to putting the opening curly-bracket in a comment just after the THEN and a matching closing curly-bracket in a comment before the EndIf. This is a ghetto way of allowing VI to match the start/end of the block using % keystroke.
A more elegant way would be to use some sort of IDE that understands the block concept in the language you are editing. Sometimes this feature is called a "folding editor" as per http://en.wikipedia.org/wiki/Folding_editor
As I saw else marked when my caret stood at an if (in PHP code), https://google.com/search?q=jump+between+if+and+else+in+vscode brought me here, and patching together various hints led me to the following commands, bound in Visual Studio Code aka VSCode
# Command Palette (⌘+⇧+P # macOS)
Go to Previous Symbol Highlight
Go to Next Symbol Highlight
Reverse engineered default F7 / ⇧+F7 # keybindings.json:
{
"key": "f7",
"command": "editor.action.wordHighlight.next",
"when": "editorTextFocus && hasWordHighlights"
},
{
"key": "shift+f7",
"command": "editor.action.wordHighlight.prev",
"when": "editorTextFocus && hasWordHighlights"
},
To fit the right hand over a numpad keyboard, and having a lot of combinations bound to other commands, my keybindings.json (syntax is .jsonc - JSON with Comments) adds:
{
"key": "ctrl+numpad_subtract",
"command": "editor.action.wordHighlight.prev" // "Go to Previous Symbol Highlight"
},
{
"key": "ctrl+numpad_add",
"command": "editor.action.wordHighlight.next" // "Go to Next Symbol Highlight"
},

Does the Sublime Text 2 Build System accept input, if does not are there any workarounds?

Objective
Set up a Sublime Text 2 Build System that allows to compile and run C programs. I have been able to painfully get to this point, but now I have some things that I cannot figure out so my two mains questions:
1) I hit ctrl+b (it compiles successfully), then ctrl+shift+b and the script runs by it doesn't take any input? Is this normal?
2) If Sublime Build Systems do not take input, there must be some workarounds. For example I press ctrl+b Sublime Text 2 compiles the file but when I press ctrl+shift+b, Sublime launches cygwin, navigates to my current directory, then does ./filename.c. Is this possible? Here it says Sublime Text 2 suppresses GUIs but it is possible to make to make Sublime open MATLAB with the build system, so maybe I can do the same thing with Cygwin?
{
"cmd" : ["gcc", "-std=c89", "-pedantic", "-Wall", "$file_name", "-o", "${file_base_name}.exe"],
// "cmd" : ["bash ${file_base_name}.exe"],
"selector" : "source.c",
"path" : "C:/cygwin64/bin/",
"shell":true,
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
//"working_dir" : "$file_path"
"variants": [
{
"cmd" : ["${file_base_name}.exe"],
"name": "Run"
}
]
}
Thanks for looking.
EDIT
I am trying to give input to my executable when it runs. For example my script prompts the user to enter in a number, letter, string, etc using scanf or getchar(), and then store the result in a variable that I will use later on. Right now when I press ctrl+shift+B in Sublime Text it runs but skips all the input stuff.
That is my current build system. If it not possible to use Sublime Text 2 to enter in input, then i want to modify it to Sublime launches cygwin, navigate to my current directory, then do ./filename.c.
Someone over at the sublimetext channel on the freenode irc helped me out and answered my questions (shoutout to them on stackoverflow #Zren). Here is the final working script:
Description
Ctrl+b compiles the "C" script using Cygwin (with the flags -std=c89, -pedantic, -Wall)
If there are any errors you can see them underneath your code straight in the Sublime integrated window
Press f4 and shift-f4 to navigate through them in Sublime Text
If there are no errors it says finished in so and so seconds
Ctrl+shift+b runs the script, it opens command prompt in a new window and runs the script there, and you can give input (Yay! :))
Code
{
"cmd" : ["gcc", "-std=c89", "-pedantic", "-Wall", "$file_name", "-o", "${file_base_name}.exe"],
"selector" : "source.c",
"path" : "C:/cygwin64/bin/",
"shell":true,
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"variants": [
{
"cmd": ["start", "cmd", "/k", "${file_base_name}.exe"],
"name": "Run",
"shell": true
}
]
}
In the future
Hopefully Google can lead people here since Sublime Text 2 documentation is very poor, and I don't want anybody else to struggle with this simple yet time consuming problem.
Tags: Sublime Text 2, gcc, cygwin, build, c, input, Windows

Sublime Text 2 Error Trailing comma before closing bracket

I changed the user setting from preference and saved it. Then i tried to open editor but i get the error message. So i uninstalled and installed it again. Though, no use. Also the path mentioned in the error message also is not there.
The error message is:
Error trying to parse setting: Trailing comma before closing bracket in C:\Users
Rajanand\AppData\Roaming\Sublime Text 2\Packages\User\Preferences.sublime-settings:5:1
What am I missing here?
Go to Preferences > Settings - User. AppData is hidden by default in Windows, show with the explorer's folder options.
Your problem is that you have an extra comma somewhere in that file. Remove the comma from the last setting in any list. Without seeing that file, I can not tell you where exactly. Here are examples:
{
setting1,
setting2,
last_setting,<-- remove
}
Remove the comma from the last setting.
or
{
setting1,
setting2:
[
setting2_item1,
setting2_last_item,<-- remove
]
}
Remove the comma from setting2_last_item.
or
{
setting1:
[
setting1_item
],
setting2:
[
setting2_item
],<-- remove
}
Remove the comma after setting2's list.
The above answers helped me out on sublime text 3
But just wanted to add this...
For newbies like me, if you want to add your custom settings and you tried adding it to the Preference file and you're getting the error too... In my case I did like the following...
{
"ignored_packages":
[
"Vintage"
], // <-- I put the comma there so I can add the below, new setting.
"tab_size": 2 //My new setting
}