If only Photoshop was InDesign when it came to text!
I don't know if this is possible using the standard Edit > Find and Replace Text... command.
It is possible to script using a regular expression based find/replace, however, if you have different text attributes (sizes, colours etc) then the following code may not work correctly (this script changes all text layers from comma+space to comma+return):
/*
Text Replace Comma Space for Comma Return in All Text Layers and Groups.jsx
v1.0 - 25th July 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-adding-line-break-behind-every-comma-of-text-layer/m-p/14753971
*/
#target photoshop
if (app.documents.length > 0) {
var doc = app.activeDocument;
processLayersAndGroups(doc.layers);
} else {
alert("A document must be open to run this script!");
}
function changeTextContents(layer) {
// Check if the layer is a text layer
if (layer.kind == LayerKind.TEXT) {
// Regular expression to change comma+space to comma+return
layer.textItem.contents = layer.textItem.contents.replace(/\, /g, ',\r');
}
}
function processLayersAndGroups(layers) {
// Recursively process the root/top-level layers
for (var i = 0; i < layers.length; i++) {
var layer = layers[i];
if (layer.typename == "ArtLayer") {
changeTextContents(layer);
// Recursively process the layers within all groups
} else if (layer.typename == "LayerSet") {
processLayersAndGroups(layer.layers);
}
}
}