Line breaks on string literals


Hi, excuse my ignorance I searched everywhere and could not find it anywhere

Is there a way to configure atom to automaticaly break lines when pasting into “” só that the text becomes the string concatenated ?


So you’re asking for a feature where if I have the following text in the clipboard:

blah blah blah blah blah
foo foo foo foo foo foo
bar bar bar bar bar bar

And I have my cursor between a pair of double-quotes then paste the text in, you want this to be the result?

"blah blah blah blah blah"
"foo foo foo foo foo foo"
"bar bar bar bar bar bar"


That wouldn’t be concatenated. You need to have the concatenation operator +.

I’m getting deja vue. Maybe a package was just announced for this?


Some languages, including C, concatenate string literals that are separated only by whitespace. I’ve seen it cause just as many nasty bugs as the number of times that I’ve seen it be useful … but some people like the feature.


Bash does that also.


Yes it should be

“blah blah blah blah blah \n” +
“foo foo foo foo foo foo \n”+
"bar bar bar bar bar bar ";

I find it usefull because often I have to write complex DB queryes this way it keeps identation when I see it in my console


There’s nothing built-in to Atom that does this, no. It sounds like a great idea for a package though :grinning:


I use this. It almost gets you what you want.

It splits whenever your press enter with a cursor in a string. I’m surprised it doesn’t happen by accident more often. One place it has a problem is in long herestrings where every enter, even at the end of a line, messes things up. I’ve been putting off posting an issue or a PR.


Thanks, I am using it in fact … togheter with and I first encode the text to query quote it then break rhe lines at \n with enter


This is so simple and works so well that it should be built in. I can’t think of any reason why you wouldn’t want it to work like this?