3

Anyone knows how would one merge such list as

item 1  item 2
item 3  item 4

to

item 1 
item 2 
item 3 
item 4 

in TextMate or TextWrangler?

1 Answer 1

1

How are the columns separated? By a \t? If so, you just want to replace this with a newline. If they aren't separated by a tab, the procedure is the same – just copy the column separator, whatever it is. Two spaces for example should work just fine, as will a , when working witha CSV.

item 1  item 2
item 3  item 4

The procedure's fairly easy:

  • Copy the tab character from the text field with Cmd-C (it might help to have View → Show Invisibles enabled)

    enter image description here

  • Open a search/replace window with Cmd+F.

  • Paste the copied tab character into the "Find" field with Cmd-V.

  • In the "Replace" field, press alt+Enter to get a new line.

It'll look like this (yes, you can't see anything, but you can select the contents to see everything's there).

enter image description here

Then, click "Replace All". Result:

item 1
item 2
item 3
item 4

As @romainl points out, it's also possible to use Regular Expressions for that. If you know the separator is Tab (\t), just check "Regular expression" and enter \t for "Find" and \n for "Replace.

enter image description here

2
  • One could also check the "Regular Expression" checkbox and type \t in the "Find:" textfield and \n in the "Replace:" textfield.
    – romainl
    Jul 8, 2011 at 11:42
  • Yup, didn't want to include it at first because with Regular expressions you'd have to read up what to use if your separator is not \t. I added that to the answer though, thanks for pointing out.
    – slhck
    Jul 8, 2011 at 11:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .