YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

Multi-Line find & replace #6550

Open Ryuhouji opened 3 months ago

Ryuhouji commented 3 months ago

Is your feature request related to a problem?

When I need to add a field to a structure that contains many and/or multiple members, there's no way to highlight a very specific chunk of text and replace every instance of that (multiline) specific text with another (multiline) chunk of text.

Describe the solution you'd like

I'd like to be able to find and replace multiline selections. I'll give an example

If I have an array of structs for all of the battle skills that exist in my game that has maybe hundreds of entries, and I wanted to add a new datapoint for them such as secondary damage or wether it makes physical contact, or whatever, I want to add a field to every struct in the array of over 100 battle skills, rather than doing this manually, I highlight the comma after "War Cry" to the colon of description and replace with that same text, but the line makesContact: false in the middle of it.

#macro battleMoves global.skillsLibrary
global.skillsLibrary =
[
        {
            //multiple dozens or hundreds of entries up here},
        }
    {//War Cry
        name : "War Cry",//highlight here to
        description: /* < here  */ "Increase max HP of party members with a morale boost.",
        displayText : "",
        skillIcon: sprWarCryIcon,
        targetType: TARGET_ALL_ALLY,
        subtype: ST_BASIC,
        actionAnim: PLAYER_CAST,
        damageType: ELEMENT_NONE,
        status: STATUS_NONE,
        statusChance: 0.0,
        resCost: 3,
        actionScript: SkillScript_WarCry,               
    }
];

and replace with

,//highlight here to
                makesContact: true,
        description:

Describe alternatives you've considered

I don't know of any alternatives that could be considered, this is very specific.

Additional context

replace this: https://i.imgur.com/KG3OdPM.png with https://i.imgur.com/M0VIeD7.png

Alphish commented 3 months ago

What might help is introducing something akin to Extended search-and-replace mode from Notepad++: https://npp-user-manual.org/docs/searching/#extended-search-mode

Or even straight-up Regular Expressions: https://npp-user-manual.org/docs/searching/#regular-expressions

Then in an extended mode, assuming all instances of description: " text are part of the skills definitions (which should work if you keep search limited to the skills library script), you could search for: description: " and replace it with: makesContact: true,\n\t\tdescription: " where \n gets translated to a newline, and \t gets translated to a tab.

Until the feature gets implemented in GM proper, you might want to keep Notepad++ at hand with its enhanced search and replace capabilities, but I agree it would be good to have in GM as well. ^^

Ryuhouji commented 3 months ago

I apprecaiate that advice, however, I currently use VSCode for this functionality. I was directed to post this request here by someone in the GM discord because it's a useful feature for anyone who wants/needs it, and does no harm to anyone who doesn't.