sublime text 2 word wrap setting doesn't work - sublimetext2

I put this preference.sublime-settings,
{
"ignored_packages":
[
"Vintage"
]
"word_wrap": true
}
But the error comes out like this when I save it: Error trying to parse settings: Unexpected character, expected a comma or closing bracket in ~/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings:7:2
what's wrong with this?

You might be facing this problem because the previous property didn't end with a comma. Make sure that there is a comma before you enter any new property. Like there is after font_size in the following illustration.
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"word_wrap": true

I should have edited Preference.sublime-settings-Default instead of User. That was the problem.

Related

Method to make themes in vscode conditional

I use bracket pair colorizer. Is it possible that the bracket pair settings can be modified if the theme is (for example) monokai?
Ik its a json file and json files dont accept if statements, otherwise id write:
if "theme" == "monokai" {
bracket-pair-colorizer-2.colors: [
"red",
"green",
"blue"
]
}, else {...}
Is there any way to make this reality?
Edit:
I tried setting editor.tokenColorCustomizations's brackets option to a list, and string, then tried that with parenthesis, and bracket, but it simply said that it cannot do that

How to fill/change particular unknown strings of some sections of a well formated JSON file from bash keeping the format intact?

How to fill/change particular unknown strings of some sections of a well formated .json file from bash keeping the format intact ?
Details:
Part of settings.json :
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
},
"theme": "dark",
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"acrylicOpacity": 0.9,
"colorScheme" : "Material",
"cursorColor" : "#FFFFFD",
"useAcrylic" : true
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false,
"acrylicOpacity": 0.2,
"colorScheme" : "Frost",
"cursorColor" : "#000000",
"useAcrylic": true,
},
"schemes": [
{
"name" : "Frost",
"background" : "#ffffff",
"black" : "#3C5712",
"blue" : "#17b2ff",
"brightBlack" : "#749B36",
"brightBlue" : "#27B2F6",
"brightCyan" : "#13A8C0",
"brightGreen" : "#89AF50",
"brightPurple" : "#F2A20A",
"brightRed" : "#F49B36",
"brightWhite" : "#741274",
"brightYellow" : "#991070",
"cyan" : "#3C96A6",
"foreground" : "#000000",
"green" : "#6AAE08",
"purple" : "#991070",
"red" : "#8D0C0C",
"white" : "#6E386E",
"yellow" : "#991070"
},
another file pickcolor.txt:
#FFFAFA
#FFFAFA
#EEE9E9
#FFC1C1
#EEB4B4
#CDC9C9
#F08080
#FF6A6A
#CD9B9B
#EE6363
#BC8F8F
#FF4040
#FF3030
#EE3B3B
#CD5C5C
#CD5555
#EE2C2C
#8B8989
#CD3333
#FF0000
#FF0000
#8B6969
#CD2626
#EE0000
#B22222
#A52A2A
#CD0000
#8B3A3A
#8B2323
Want to create a bash which changes value of fields like "background", "cursorColor" to any random value from pickcolor.txt
Requirements/problems I am facing:
Fields appearing many times gets different values from each other
Value of fields changes from time to time, so simple find and replace do not work
Fields changes there line number every time new contents are added, so line number for fields do not remain same.
Format of .json file should not change
Please note : I do not want anyone to write the complete code ; just hinting/pointing out ways will be sufficient. And thanks in advance !!
I believe what you need is something like this
fields=(background cursorColor)
colors=("#FFFAFA" "#CDC9C9" "#EE3B3B")
size=${#colors[#]}
for f in "${fields[#]}"; do
for line in $(grep -n "\"$f\"" myfile.json | cut -f1 -d:); do
index=$(($RANDOM % $size))
color="${colors[$index]}"
sed -i $line's|\("'"$f"'"\s*:\s*"\).\+"|\1'"$color"'"|' myfile.json
done
done
There is some magic in this solution:
We choose random index from array of colors
For each of fields which should be replaced we create it's own unique sed expression, which
First part (\("'"$f"'"\s*:\s*"\)#.\+" finds anything matching pattern "<field name>"<spaces>:<spaces>"<any color>"
Captures anything until 3rd double quote into group
In second group (\1'"${colors[$index]}"'") replaces matched part with itself, but inserts randomly picked color from array into second double quote group
Weird things with lots of quotes are made to interpolate field name and color into single quotes
NB: this is tested with GNU sed. May need a bit different syntax for BSD

How to mass-replace text in "sounds" : ["test/test"]

I'm trying to make a resource pack in Minecraft, and I'm replacing it so there's only one sound. When I went to go and edit sounds.json in VSC, I want to set all the locations to just one file. It should look like this :
"sounds" : [
"test/test"
],
to test/test for all the "sounds". But I have no idea of how to do this. The sounds.json file is so big it would take more than a day to do all the work by hand. So I checked to see if VSC had any options to replace the text. There wasn't.
I've tried looking around in VSC and there wasn't anything useful.
I've tried replacing all the sounds by pasting .ogg files and renaming them, it took too long, so I realized I could just set all the locations to point at one sound file.
I've gone on Google to do some research but found nothing of use.
"block.enderchest.open": {
"sounds": [
"test/test"
],
"subtitle": "subtitles.block.chest.open"
},
"block.fence_gate.close": {
"sounds": [
"block/fence_gate/close1",
"block/fence_gate/close2"
],
"subtitle": "subtitles.block.fence_gate.toggle"
},
"block.fence_gate.open": {
"sounds": [
"block/fence_gate/open1",
"block/fence_gate/open2"
],
"subtitle": "subtitles.block.fence_gate.toggle"
},
"block.fire.ambient": {
"sounds": [
"fire/fire"
],
I expect a convenient way in order to edit "sounds" : [] []'s all at once.
The actual result is not really a convenient way and a time waster to edit all of the sounds [] values.
One way to do it is with regex, see regex101 demo.
Search for : ("sounds": \[\n)((\s*)[^\]]*\n)*(\s*\],)
Replace with: $1$3"test/test"\n$4

How to configure WebStorm to not wrap comments to the next line

I have the following in my code:
"no-sequences": ["error"], // Disallow Use of the Comma Operator
"no-throw-literal": ["error"], // Restrict what can be thrown as an exception
After I reformat my code with Ctrl+Alt+L I get the following:
"no-sequences": [
"error"
],
// Disallow Use of the Comma Operator
"no-throw-literal": [
"error"
],
// Restrict what can be thrown as an exception
As you can see, the comments are wrapped to next line.
Is there any way to configure WebStorm to not wrap comments or put them before the corresponding code, and not after?

Missing quotes in Json file

I have a very large Json file. It contains 27000 records.
a record looks like this:
{
adlibJSON: {
recordList: {
record: [
{
#attributes: {
priref: "4372",
created: "2011-12-09T23:09:57",
modification: "2012-08-11T17:07:51",
selected: "False"
},
acquisition.date: [
"1954"
],
acquisition.method: [
"bruikleen"
],
association.person: [
"Backer, Bregitta"
],
association.subject: [
"heraldiek"
],
collection: [
"Backer, collectie"
], ... ...
The problem is that this is not valid Json. The quotes are missing for the names.
Like for example acquisition.date should be "acquisition.date":
I need to edit this big json file and add all the quotation marks, otherwise the file doesn't parse with for example D3.js
What is the best way to repair this Json file?
I'd use a decent text editor with regex find and replace capability (e.g., Visual Studio, UltraEdit, etc.).
Then Do: find
^\s*(\w+\.\w+)\s*:
and replace with
"$1":
Or you could use powershell:
$allText = gc yourfile.txt
$allText -replace '^\s*(\w+\.\w+)\s*:', '"$1":'
If you can open it in a text editor, I think you can simply use a replace function for:
], --> ],"
and
: [ --> ": [
If your JSON is formatted the same throughout and doesn't contain those characters, this should work.
--
Note that you'll have to manually edit the first key yourself.