All lines in a file have collapsed into one line.
-
My debug info:
Notepad++ v8.6.5 (64-bit)
Build time : Mar 29 2024 - 17:04:43
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : “E:\SteamLibrary\steamapps\common\Wartales\Extracted\Impatience overhaul\Output\data.cdb”
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
OS Name : Windows 10 Home (64-bit
OS Version : 22H2
OS Build : 19045.6332
Current ANSI codepage : 1252
Plugins :
ComparePlugin (2.0.2)
JSMinNPP (1.2006)
mimeTools (3.1)
NppConverter (4.6)
NppExport (0.4)I don’t know if this qualifies as a search/replace question so I didn’t use that template.
A mod I’m using for a game is out of date so I thought I’d try to update it. I thought the easiest way to do this would be to compare the mod’s data file to the game’s data file but when I opened the mod’s data file I saw that all of the code was smushed into one line.
In the game’s data file the code looks like this:
{ "sheets": [ { "name": "icon", "columns": [ { "typeStr": "14", "name": "icon", "opt": true }, { "typeStr": "0", "name": "id" }, { "typeStr": "1", "name": "text", "opt": true, "kind": "localizable" }, { "typeStr": "1", "name": "desc", "opt": true, "kind": "localizable" }, { "typeStr": "2", "name": "iconeDone", "editor": { "copyPasteImmutable": true } } ],
In the mod’s data file the code looks like this:
{"sheets": [{"name": "icon", "columns": [{"typeStr": "14", "name": "icon", "opt": true}, {"typeStr": "0", "name": "id"}, {"typeStr": "1", "name": "text", "opt": true, "kind": "localizable"}, {"typeStr": "1", "name": "desc", "opt": true, "kind": "localizable"}, {"typeStr": "2", "name": "iconeDone", "editor": {"copyPasteImmutable": true}}],
I know how to manually change the way the code looks on a small scale but the Game’s data file has 289,028 lines and having to manually change the mod’s data file to match that would take way too long.
I’ve tried adding new lines by using the replace function by adding new lines after the brackets and curly brackets but that only increased the total amount of lines to around 90,000.
Is there a way of changing the way the code looks in the entire file so it matches the game’s data file?
If it’s allowed I could possibly add the modded file if it helps.
-
With just Notepad++, there isn’t a great way. If you are willing to install a plugin, then I would recommend @Mark-Olson’s JsonTools plugin (to install the plugin, use Plugins > Plugin Admin, checkmark
JSON Tools
, and click Install).Once it’s installed, you can open your mod’s data file (the one that’s flat), and then use Plugins > JsonTools > Pretty-print current JSON file to make it more like the original.
(I cannot guarantee that the plugin’s pretty-print routine will exactly follow the same rules as the original game file. But if you want to look at them both with the same formatting rules, you can use Pretty-print on the original file, as well, which will make them both have the same consistent formatting.)
-
I’ve already installed a few other plugins, I don’t mind installing more.
I used the pretty-print option and it looks like it fixed the file. There’s still differences in the total amount of lines of code both files have but that’s most likely because the game’s data file has new content in it.
The only problem I have now is that it’s taking a very long time to compare the two data files.
-
@Joep-Kregting said in All lines in a file have collapsed into one line.:
The only problem I have now is that it’s taking a very long time to compare the two data files.
From your Debug Info that you shared earlier, it appears you are still using the old ComparePlugin. I would recommend uninstalling that and installing ComparePlus instead – it’s the successor to the original, and is actively maintained. I cannot guarantee it will be more efficient at the comparison, but it wouldn’t hurt.
-
Alright, I’ll try ComparePlus instead. I was already planning to let my computer run the comparison overnight so hopefully ComparePlus is faster.
-
JsonTools maintainer here.
The
sort_keys
setting in JsonTools should be set toTrue
when pretty-printing JSON for comparison.This is because the order of keys in a JSON object doesn’t matter:
{"foo": 1, "bar": 2}
and{"bar": 2, "foo": 1}
are the same, but a general-purpose diff tool like ComparePlus doesn’t know that.