0

I have a simple but annoying problem with Sublime text 2. I am writing a python script to parse through a large dataset, and I want to store this information in a database. the dataset comes with some pre-created SQL statements.

however, I can't simply copy paste them into the script because they are each on a newline. Is there a sublime shortcut for stripping these.

tl;dr

how can I turn this:

record_id serial PRIMARY KEY,
  vin_id integer,
  plate_id integer,
  me_id integer,
  etc.

into this

record_id serial PRIMARY KEY, vin_id integer, plate_id integer, me_id integer

using a simple copy/paste or similar command in sublime text 2?

majidarif
  • 18,694
  • 16
  • 88
  • 133
Mike
  • 397
  • 5
  • 19
  • In general, you can use regex in find and replace panel. Could you please provide more records? It is hard for us to provide correct regex due to lack of information. – longhua Mar 13 '14 at 04:36
  • You can also use multiple selections. Refer to this post: http://stackoverflow.com/questions/13066068/remove-add-line-breaks-after-specific-string-using-sublime-text – longhua Mar 13 '14 at 04:41
  • You can easily use triple quotes to include multi-line SQL instructions in Python scripts. – MattDMo Mar 13 '14 at 13:57

2 Answers2

1

Highlight the text and then hit super + j on Mac, or ctrl + j on Windows and Linux.

angerson
  • 7,342
  • 1
  • 21
  • 24
AGS
  • 14,288
  • 5
  • 52
  • 67
0

https://github.com/vlakarados/SublimeLineWorks

See if this package works for you (added singlify functionality just now). Had made it on ST3 so it may not function in ST2.

If it doesn't and if it will throw errors in console, I'll have to take time to get ST2 and make it compatible with py2.6.

Sergey Telshevsky
  • 12,077
  • 6
  • 55
  • 78