Jhonatan Sandoval
Jhonatan Sandoval

Reputation: 1293

Eclipse java - how to add full line with double quotes

I'm programming in Eclipse and i have a SQL script that got multiple lines:

SELECT * FROM
.... (bla bla)
... (bla bla )..
... (bla bla bla bla)

I have to add the double quotes like this:

" SELECT * FROM "
+ ".... (bla bla) "
+ "... (bla bla ).."
+ "... (bla bla bla bla) "

Is there any SHORTCUT to do this in Eclipse?

EDITED:

I have a SQL script that got like 50 lines (for examp.):

line 1: SELECT * FROM 
line 2: HR_EMPLOYEES
line 3: ... (bla bla)
.
.
.
line 50: AND NAME like 'AP%'

I have to do in every line this:

+ " (CODE SQL) "
+ " (CODE SQL) "

MANUALLY.

Is there any shortcut to do this ( + " " ) in eclipse java language?

Upvotes: 2

Views: 3735

Answers (5)

Sreerang
Sreerang

Reputation: 1

  1. Simply define a String in Eclipse like private final String selSQL="";
  2. Copy-paste your query between the double quotes
  3. Press Enter key at any end of word, the eclipse automatically appends double quotes "", followed by concatinator + on the same line, and double quotes " in the next line for the continuation.
  4. Use Del and End to continue for the rest, until all lines are concatinated.

Upvotes: 0

Jagger
Jagger

Reputation: 10524

Use column selection Alt + Shift + A and then select the "beginnings" of the lines and simply type + " then do the same for the end of lines but type ". This will insert typed characters in all of the selected lines.

I attach a short video on how I do it in Eclipse.

Upvotes: 2

rec
rec

Reputation: 10895

So you have this situation

some text
some text

and want to arrive at

"some text"
+ "some text"

The easiest I can imagine is this: replace linebreaks with "(linebreak)+ "

1) write this somewhere

"
+ "

2) mark that from " to " text and copy it

3) open the search/replace dialog

4) paste to the "replace with" field (yes, you can paste strings with new lines there)

5) write a newline somewhere, basically a line and press "enter" immediately

6) mark this line break (start mark in first position in a the first line and end in the first position of the next line)

7) cut and past into the "find" field (mind that nothing will appear there!)

8) mark all the text you want to fix up

9) select scope: selected lines

10) replace all

11) add extra " in the first line and remove extra +" in the last line

"some text"
+ "some text"

Shortcut? Well, if you have many lines to fix up... yes, it can make a difference.

Upvotes: 0

Adam Bullock
Adam Bullock

Reputation: 109

You can type it out in one line like

"SELECT * FROM blah .... (bla bla) .... (bla bla) .... (bla bla bla)"

And then put your cursor where you want to begin on the next line, hit enter, and Eclipse will automatically add the respective ""s and +s

Or as you are typing out the query string, just hit enter when you want to go to the next line. If you are typing a string (with quotes) it will automatically add the "" and +s

Or if you are copying and pasting the query string try this out https://stackoverflow.com/a/2159931/2386700

Upvotes: 0

Jacob Cohen
Jacob Cohen

Reputation: 1272

Could you please specify the programming language you're using?

Assuming you meant java, I'd say just use the String class method called "replace"

And you will need to replace the "new line" char (\n) into " \n + ".

Hope this will help you create your solution.

Upvotes: 0

Related Questions