Sublime Text 3. Build 3126
Example:
line 1
line 2"
line 3
line 4
After select of all text and tap Ctrl+J (on linux) I get this:
line 1 line 2"line 3 line 4
As you see, there is no whitespace after symbol ". What I’m doing wrong?
Sublime Text 3. Build 3126
Example:
line 1
line 2"
line 3
line 4
After select of all text and tap Ctrl+J (on linux) I get this:
line 1 line 2"line 3 line 4
As you see, there is no whitespace after symbol ". What I’m doing wrong?
I guess the join_lines
command is hard-coded to add whitespace only after .
, ,
, !
etc.
looks like someone else also doesn’t like the way it works, so they created a plugin with the functionality they wanted:
https://packagecontrol.io/packages/JoinLinesEnhanced
Even if what you say is true, I don’t think that it is true behavior. If it’s not a bug, then, maybe, developers might to fix it in further versions, because now it beings “wow”-effect
If you absolutely can’t fix it manually, you could
search: (\S)"(\S)
where: (your current file)
replace: ${1}" ${2}
Enable regex search for this.
\S
means “any non-whitespace character”, so, \S"\S
means “any non-whitespace character, followed by a double quote, followed by any non-whitespace character”. Now, anything within parentheses means “capture what is in the parentheses”, so, (\S)
means “capture the non-whitespace character”. So, (\S)"(\S)
is what you think it means.
To retrieve those captures, you can use ${1}
(or $1
for short) to reference the first capture, ${2}
to reference the second capture, and so forth.
So, if you replace the search with ${1}" ${2}
, then that means “insert the first captured non-whitespace character, then insert a double-quote, then insert a space, and then insert the second captured non-whitespace character”.
For example, here:
line 1 line 2"line 3 line 4
the search would match
2"l
because 2
is non-whitespace and l
is non-whitespace. This would be replaced by
2" l
You must enable the “regex search” option for all this to work:
This behaviour is very annoying when using vintage mode.
What’s the reasoning behind it?
Suggestion: make “join lines” consistent by always adding a whitespace and provide another version for joining without spaces (or just let people use JoinLinesEnhanced
plugin when they want that)