is there any way to move cursor multiple lines at the time in sublime text with keyboard shortcut instead of one line at the time? - cursor

I used to move cursor up and down with "UP" and "DOWN" keys.
but it can only move 1 line at the time.
sometimes I would love to move 2 or 3 lines at the time.
i'm wondering if thers's such feature in sublime text editor ?

You can record a macro (CTRL+Q or Tools -> Record/Stop Macro) and save it (just use cursor up/down as often as you like.
Then assign a key or key-combination to the macro file. The key assignement has to look like this. I called the macros "multiple_lines_down" and "multiple_lines_up".
Then assign the macros to your keymap:
{ "keys": ["alt+down"], "command": "run_macro_file", "args": {"file": "Packages/User/multiple_lines_down.sublime-macro"}},
{ "keys": ["alt+up"], "command": "run_macro_file", "args": {"file": "Packages/User/multiple_lines_up.sublime-macro"}},
Macro-File (5 times up) looks like this. Replace false with true to move downwards or just record another macro.
[
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": false
},
"command": "move"
}
]

Related

Setting up VS Code for C using Cygwin64 Compiler and Debugger on Windows (ERROR: Unable to start debugging)

I am trying to set up VSCODE to debug a C program on Windows using Cygwin64.
I used the config suggested by #stephw ( Setting up VS Code for C using Cygwin64 Compiler and Debugger on Windows ), but it did not work for me.
I cannot comment on the original post, because I do not have enough reputation points, and I cannot answer because I do not know the answer to the original question.
The name of the script is dirigir.c and I can compile. The file dirigir.exe is created. But...
I get the following error:
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Error creating process /usr/bin/E:\cloud\Backup\Trabalhos com programas\C and Cpp\scripts/e:\cloud\Backup\Trabalhos com programas\C and Cpp\scripts\dirigir.exe, (error 2).
For some reason, /usr/bin/... / is inserted in the path and the path to the .exe is duplicated.
My launch.json file is as recommended:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PATH",
"value": "%PATH%;z:\\cygwin64\\bin"
}
],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"logging": { "engineLogging": true }, //optional
"preLaunchTask": "gcc.exe build active file"
}
]
}
And my tasks.json is as follows:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:\\cygwin64\\bin\\gcc.exe",
"args": [
"-g",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-Werror", // Optional
"-Wall", // Optional
"-Wextra", // Optional
"-ansi", // Optional
"-pedantic", // Optional
"${file}"
],
"options": {
"cwd": "C:\\cygwin64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
]
}
Do you have any idea how to proceed? Thank you in advance.
Finally, I got it working.
Based on WardenGnaw's answers in this thread:
[cppdbg] Cygwin 10.1-1: intergatedTerminal unable to take input #6475 and, of course, #stephw's answer in the original question this one is based, I can debug my C program.
First, I saved a VSCODE workspace in the same folder where my c programs are.
Then, I used the latest Cygwin gdb version (10.2-1). Did not work (I received the error message that made ask this question). Then, I tried 9.2-1 and now it is working.
It is important to remember to add "C:\cygwin64\bin" to PATH.
I changed my launch.json just a little bit. Notice the "preLaunchTask" key does not have the exact same value that the "label" key in the tasks.json has:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PATH",
"value": "%PATH%;C:\\cygwin64\\bin"
}
],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"logging": { "engineLogging": true }, //optional
"preLaunchTask": "gcc.exe build active file"
}
]
}
My tasks.json is this (notice my name in the end, in the "detail" key):
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\cygwin64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Leonardo."
}
]
}
I notice something a little bit strange:
When I press F5, it does not work, because the task created is not found.
When I edited my launch.json file (preLaunchTask key) to the exact same value in the tasks.json file, the "not found" error disappears, but the debugging process does not start.
"preLaunchTask": "C/C++: gcc.exe build active file"
If I press the Run and debug play button, the debug process does not work either.
When I use the Command Palette (pressing CTRL+SHIFT+P), and click C/C++: Build and Debug Active File,
and then choose the task I created (the second one appears to be automatic),
the program is compiled and the debug process is started.
This is my very simple test script:
#include <stdio.h>
#include <stdlib.h>
int main() {
/* declare and initialize string */
char myString[] = "This is an example of string declaration!";
/* print string */
printf("%s", myString);
int numberA = 5;
int numberB = 10;
int sum = numberA + numberB;
/* Printing a number */
printf("A soma de numberA + numberB é: %d", sum);
return 0;
}
I hope this question and answer can help someone in the future. Peace.
None of the .json changes described here worked for me with gdb 10.2-1. The only thing that did work was the downgrade to gdb 9.2-1, which solved the problem instantly.

ECS task change

I am trying to check the last status of an ECS task, if it is STOPPED then it has to trigger lambda using cloudwatch event. I am getting below error message while validating the JSON event.
Error message:
Event pattern contains invalid element (can only be Strings enclosed in quotes, numbers, and the unquoted keywords true, false, and null)
**Code**:
{
"source": [
"aws.ecs"
],
"detail-type": [
"ECS Task State Change"
],
"detail": {
"clusterArn": [
"arn:aws:ecs:us-west-2:17025:cluster/ecs-w2"
],
"lastStatus": [
"STOPPED"
],
"overrides": {
"containerOverrides":
{
"environment":
{
"name": ["job_grp_nm"],
"value": ["QA_INTEGRATION"]
},
{
"name": ["secrets_targetdb"],
"value": ["7034908/Snowflake/facilitiesNDI/QA"]
},
"name": ["suite-dev"]
}
}
}
}
Please let me know what's wrong with the code.
There are two things wrong:
The values should be expressed as array of string, e.g. ["value"]
Your environment can be an array of objects.
So it should be:
{
"source": [
"aws.ecs"
],
"detail-type": [
"ECS Task State Change"
],
"detail": {
"clusterArn": [
"arn:aws:ecs:us-west-2:17025:cluster/ecs-w2"
],
"lastStatus": [
"STOPPED"
],
"overrides": {
"containerOverrides":
{
"environment":
{
"name": ["job_grp_nm"],
"value": ["QA_INTEGRATION"]
},
"name": ["suite-dev"]
}
}
}
}
The above should be accepted, but I can't verify if this will correctly match your event.

VSCode keybinding to navigate to render method

so I am using VSCode for react development and I was wondering if I could jump to the render function with a shortcut. Naturally there is no preconfigured way. So I looked into it and found a GitHub issue.
{
"key": "shift+alt+p",
"command": "workbench.action.quickOpen",
"args": "#:render"
},
Problem is, that the shortcut opens up the vscode window. Which is prefilled and I have to press the enter button to do the actual "navigate to". Does anyone know how to do this without pushing enter?
I think the only way is to use a macro to run both the quickOpen command and selecting with one keystroke.
Using a macro extension like multi-command, put this into your settings:
"multiCommand.commands": [
{
"command": "multiCommand.goToRender",
"sequence": [
{
"command": "workbench.action.quickOpen",
"args": "#:render"
},
"workbench.action.acceptSelectedQuickOpenItem"
]
}
]
and some keybinding to trigger that macro (in your keybindings.json):
{
"key": "shift+alt+p",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.goToRender" },
"when": "editorTextFocus"
}
Of course, if you have multiple render objects the first will be selected and navigated to.
An alternative is to use the selectBy extension which you could configure to jump to the next or previous occurrence of the word render. The extension can move to occurrences of words (and not select anything). In your settings:
"selectby.regexes": {
"goToRender": {
"moveby": "render",
}
}
And some keybindings (whatever bindings you want):
{
"key": "shift+alt+p", // go up to the previous `render`
"when": "editorTextFocus",
"command": "moveby.regex",
"args": ["goToRender", "moveby", "prev", "start"]
},
{
"key": "alt+p", // go to the next `render`
"when": "editorTextFocus",
"command": "moveby.regex",
"args": ["goToRender", "moveby", "next", "start"]
},

schemaform adding the user input to a schema array

Background
I am making a form using angular-schema-form
Setup
I am trying to make an array of items that a user can make using a form. So, the user can add as many items into the array as they want.
For now the items in the array contain a command type.
Command Type should be a dropdown containing SSH, REST, and whatever the user enters in as the personalized command type.
Code so far
SCHEMA
{
"type": "object",
"properties": {
"personalizedCommandType": {
"title": "Personalized Command Type",
"type": "string"
},
"commands": {
"type": "array",
"title": "Actions",
"items": {
"type": "object",
"properties": {
"commandType": {
"title": "Command Type",
"type": "string",
"enum": [
"REST",
"SSH"
]
}
}
}
}
}
}
FORM
[
{
"type": "help",
"helpvalue": "<h5>Command</h5>"
},
{
"key":"personalizedCommandType"
},
{
"title":"Command",
"key": "commands",
"items": [
"commands[].commandType"
]
}
]
One can test this code here: http://schemaform.io/examples/bootstrap-example.html . Just copy and paste in my code.
Question
As one can see, the code I have now has a field with Personalized Command Type and an array of dropdowns with the 2 options SSH and REST. But I want to drop to also contain the value of the Personalized Command Type once the user has entered it.
NOTE
copyValueTo does not seem to have the functionality that I want given that it can only change values in the model, but I want it to change the enum array in the schema.
Use the onChange option:
[
{
"type": "help",
"helpvalue": "<h5>Command</h5>"
},
{
"key":"personalizedCommandType"
onChange: "updateSchema(modelValue,form)"
},
{
"title":"Command",
"key": "commands",
"items": [
"commands[].commandType"
]
}
]
Update the Schema:
var defaultEnum = ["REST","SSH"];
$scope.updateSchema = function(modelValue,form) {
var currentEnum = $scope.schema.commands.items.properties.commandType.enum;
angular.copy(defaultEnum, currentEnum);
if (modelValue) {
currentEnum.push(modelValue);
};
$scope.$broadcast('schemaFormRedraw');
};

minItems doesn't seem to validate correctly in JSON schema

I'm writing a simple JSON schema and using minItems to validate the number of items in a given array. My schema is as follows:
{
"title": "My Schema",
"type": "object",
"properties": {
"root": {
"type": "array",
"properties": {
"id": {
"type": "string"
},
"myarray": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 4,
"uniqueItems": true
},
"boolean": {
"type": "boolean"
}
},
"required": ["id","myarray","boolean"]
}
},
"required": [
"root"
],
"additionalProperties": false
}
Now I would expect the following JSON to fail validation given the element myarray has nothing in it. But when using this online validator, it passes. Have I done something wrong or is the schema validator I'm using faulty?
{
"root":[
{
"id":"1234567890",
"myarray":[],
"boolean":true
}
]
}
I am not sure why or what it is called, but the correct schema definition for your requirement should be as shown further down.
From what I understand from the JSON Schema definitions, you should declare the properties of an array inside the items declaration. In your schema you where defining properties outside of the array item declaration.
In your schema you have the two different types of array declaration:
Once with just a single object (a string for the "myarray" object)
Once with a complex object (the object name "myComplexType" in the code below)
Have a look at the definitions of both, how they are structured and how they would be interpreted.
The corrected schema:
{
"title": "My Schema",
"type": "object",
"properties": {
"root": {
"type": "array",
"items": { <-- Difference here - "items" instead of "properties"
"type": "object", <-- here - define the array items as a complex object
"title": "myComplexType", <-- here - named for easier referencing
"properties": { <-- and here - now we can define the actual properties of the object
"id": {
"type": "string"
},
"myarray": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 4,
"uniqueItems": true
},
"boolean": {
"type": "boolean"
}
}
},
"required": [
"id",
"myarray",
"boolean"
]
}
},
"required": [
"root"
],
"additionalProperties": false
}
Remove the comments I added with <-- when copying over to your code, added for pointing where there changes are.
As a note, I do however don't understand why the validator didn't give an error for the 'malformed' schema, but might just be that it saw the definition as you had it as additional properties, not entirely sure.
The only thing wrong with your schema is that the root property should have type object instead of array. Because the properties keyword is not defined for arrays, it is ignored. Therefore, the part of the schema you were trying to test was completely ignored even though it was correct.
Here is the relevant passage from the specification
Some validation keywords only apply to one or more primitive types. When the primitive type of the instance cannot be validated by a given keyword, validation for this keyword and instance SHOULD succeed.
http://json-schema.org/latest/json-schema-validation.html#rfc.section.4.1

Resources