How can I join two lines in TextWrangler?

1,848 views
Skip to first unread message

Jonathan Gordon

unread,
Nov 16, 2011, 9:29:33 PM11/16/11
to textwr...@googlegroups.com
In other text editors I've seen the feature where pressing some keyboard shortcut (e.g., CTRL+J) will join the current line with the next line. Multiple calls will "suck up" subsequent lines. I find this handy in a number of situations. Does TextWrangler have this feature, or something similar, or is there an easy way for me to script this?

Thanks!

Jonathan

Roy McCoy

unread,
Nov 17, 2011, 7:09:18 AM11/17/11
to textwr...@googlegroups.com
Jonathan Gordon wrote:

> In other text editors I've seen the feature where pressing some keyboard shortcut (e.g., CTRL+J) will join the current line with the next line. Multiple calls will "suck up" subsequent lines. I find this handy in a number of situations. Does TextWrangler have this feature, or something similar, or is there an easy way for me to script this?

From the way you describe what you want to do, it sounds like you could simply script changing the next return to a word space. I too recall having this function in an editor or two - Vantage I think, maybe BBEdit - but I get it now using the QuicKeys reformat function (Text > Text Tools > Reformat), which I've assigned to my old keycode for this, cmd-ctrl-`.


Roy McCoy

Nestor E. Aguilera

unread,
Nov 17, 2011, 8:20:22 AM11/17/11
to textwr...@googlegroups.com

If the idea is to put together parts separated by one carriage return, "\r", you could use "remove line breaks" in the "text" menu (and assign a keyboard shortcut to it, mine is ctrl-\), the "inverse" operation is "hard wrap" or "add line breaks" in the same menu.

If there are two (or more) contiguous carriage returns, leaving blank lines in between, you could delete them (or forward delete them) one at a time (or use the replacement "\r+" -> "" or something similar).

Hope it helps,

Nestor

Roy McCoy

unread,
Nov 17, 2011, 9:05:27 AM11/17/11
to textwr...@googlegroups.com
Nestor E. Aguilera wrote:

> If the idea is to put together parts separated by one carriage return, "\r", you could use "remove line breaks" in the "text" menu (and assign a keyboard shortcut to it, mine is ctrl-\),

Oh, so it *is* there in TextWrangler - good to know.

> the "inverse" operation is "hard wrap" or "add line breaks" in the same menu.

I've used Hard Wrap, also combined in macros - but I was unaware of Add Line Breaks, which looks really handy. With that, instead of having to try and guess or figure out how wide your text window is and maybe adjust it or the hard wrap setting, you can get the lines broken however they're displayed at whatever window width.

> If there are two (or more) contiguous carriage returns, leaving blank lines in between, you could delete them (or forward delete them) one at a time (or use the replacement "\r+" -> "" or something similar).

I have an InDesign script I use sometimes that changes multiple carriage returns to XXX, changes single returns to word spaces, and finally changes the XXX's back to returns. This gets rid of extra line spaces while conserving (unbroken) paragraphs.


Thanks,

Roy

Isaac Wingfield

unread,
Nov 17, 2011, 11:00:07 PM11/17/11
to textwr...@googlegroups.com


    In other text editors I've seen the feature where pressing some keyboard
    shortcut (e.g., CTRL+J) will join the current line with the next line.
    Multiple calls will "suck up" subsequent lines. I find this handy in a
    number of situations. Does TextWrangler have this feature, or something
    similar, or is there an easy way for me to script this?
    There is a Services service (odd construction, I know) called "wordservice" that does many very handy things, and one of them, "Reformat", should do just what you're asking for.

    Check here:


    Isaac
    Reply all
    Reply to author
    Forward
    0 new messages