[SOLVED] Why is there no: "Convert to '...'#13#10+ " menu? lazarus / 9-Editor ---------------------------------------------------------------------- PizzaProgram · 2025-12-18 07:58 I've wasted 2+ hours to find a menu / function / plugin, which would help me to insert a multi-line SQL script as text into FPC code. (... So I do not have to put: ' signs at the beginning + end, plus add Line breaks 20-40 times for each line.)  Found nothing. Asked ChatGPT, and it confirmed, there is no such function. Provided for me a "plugin script", but that one did not compile. https://chatgpt.com/share/6943b2b1-2c4c-8000-91b6-7460243a2a14 (the 2th one either) So I wonder:  - Why are there so many other "convert to {} , etc" context editing functions,  - but this basic one is still missing after so many years of development? Most of us are working with SQL, and I can not believe nobody else is asked for this before... - Is it possible to ask for it in the next release? ---------------------------------------------------------------------- Zvoni · 2025-12-18 08:20 Has been discussed many times. As far as i can remember: Has been denied, cause it would introduce unneccessary complexity to the Source-code-parser Bottom line: write your "long" statements as you do now, or do it like i do: Don't place your SQL-Statements in the Source-code, but outside of it (Database, Text-File, sock-drawer, whatever), and pull it in, when you need it ---------------------------------------------------------------------- CharlyTango · 2025-12-18 08:57 Yes, sharing SQL statements is annoying. But there is a constant LineEnding that provides #13#10 or #10 depending on the operating system. But a programmer should be able to solve such minor issues. Two TMemos and one TButton on a form, a little code, and you get something like this in a flash from SELECT LINE 1-anyline something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i s:='';s:=s+'SELECT'+LineEnding;s:=s+'LINE 1-anyline'+LineEnding;Query1.SQL.Text:=s; ---------------------------------------------------------------------- Zvoni · 2025-12-18 09:09 Quote from: CharlyTango on December 18, 2025, 09:57:18 amYes, sharing SQL statements is annoying. But there is a constant LineEnding that provides #13#10 or #10 depending on the operating system. But a programmer should be able to solve such minor issues. Two TMemos and one TButton on a form, a little code, and you get something like this in a flash from SELECT LINE 1-anyline something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i s:='';s:=s+'SELECT'+LineEnding;s:=s+'LINE 1-anyline'+LineEnding;Query1.SQL.Text:=s; Which implies he's "constructing" his Statements at run time. Could also be he uses Constants. Both approaches are a big no-no for me Aircode for SQL-Statement in a Textfile Text-File (simple case with 3 lines. Doesn't matter if it's 3 lines or 300) Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT ID, Name, DateOfBirthFROM tbl_employeesWHERE ID=:pID Aircode for runtime Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Const f:String='SELECT-Statement-employee.txt'; //Or whichever file- extension you want to use. if i use textfiles, i use *.sqlVar Q:TSQLQuery;//....Begin  Q.Close;  Q.SQL.Clear;  Q.SQL.LoadFromFile('/My/Path/To/StatementsFolder/'+f);   Q.ParamByName('pID').AsInteger:=42;  Q.Open;End; The only thing you would need at runtime is the Filename, which statement you want to pull in ---------------------------------------------------------------------- Martin_fr · 2025-12-18 09:37 Quote from: PizzaProgram on December 18, 2025, 08:58:21 amI've wasted 2+ hours to find a menu / function / plugin, which would help me to insert a multi-line SQL script as text into FPC code. (... So I do not have to put: ' signs at the beginning + end, plus add Line breaks 20-40 times for each line.)  Menu: Edit => Multipaste ? ---------------------------------------------------------------------- dseligo · 2025-12-18 09:40 Quote from: PizzaProgram on December 18, 2025, 08:58:21 am(... So I do not have to put: ' signs at the beginning + end, plus add Line breaks 20-40 times for each line.)  You can use Multi caret to greatly speed this up: https://wiki.freepascal.org/New_IDE_features_since#Multi_Caret With Multi caret you can edit all lines at once. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 09:41 In addition, once you have a string, you can setup the IDE, to handle new linebreaks inside the string. Tools => Options => Editor => Tabs and indent Choose the "string" section at the bottom, and check "Extend String on linebreak" Then if you press enter while you are inside a string, it will add closing quote, and opening quote on the next line. And whatever other text (like "+#13#10+") you like. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 09:43 Quote from: dseligo on December 18, 2025, 10:40:37 amYou can use Multi caret to greatly speed this up: https://wiki.freepascal.org/New_IDE_features_since#Multi_Caret With Multi caret you can edit all lines at once. Especially if you enable "cursor key moves all extar carets" (which you can toggle by keycombo, if you set it up). Then you can - at the start of line use shift-alt-cursor-down => to create multiple carets (one per line) - press end, to move them all to the end of line - edit the text at the end of line ---------------------------------------------------------------------- Martin_fr · 2025-12-18 09:46 You can also use editor macros: record and repeat some editing. https://wiki.freepascal.org/IDE_Window:_Editor_Macros E.g. record: - end key - enter:  +#13#10+ - cursor down key Then repeatedly "play" the macro, and each time it will add the text to the next line. Or even use Pascal script for more complex tasks: https://wiki.freepascal.org/Editor_Macros_PascalScript ---------------------------------------------------------------------- rvk · 2025-12-18 09:47 Quote from: Martin_fr on December 18, 2025, 10:37:24 amQuote from: PizzaProgram on December 18, 2025, 08:58:21 amI've wasted 2+ hours to find a menu / function / plugin, which would help me to insert a multi-line SQL script as text into FPC code. (... So I do not have to put: ' signs at the beginning + end, plus add Line breaks 20-40 times for each line.)  Menu: Edit => Multipaste ? Haha   that's what you get with searching for 2 hours and asking ChatGPT  (and this method even handles quotes correctly, unlike the suggestions from ChatGPT) ---------------------------------------------------------------------- Martin_fr · 2025-12-18 09:51 Quote from: rvk on December 18, 2025, 10:47:16 amQuoteMenu: Edit => Multipaste ? Haha   that's what you get with searching for 2 hours and asking ChatGPT  (and this method even handles quotes correctly, unlike the suggestions from ChatGPT) It seems though that many people did not know ... Well, looking through the answers. And, yes, IMHO the name "multipaste" is not the best. Well it represents what it does (if you read "multi" as short for "multiline"), and maybe its my lack of wide enough knowledge, but most other apps that I know have this as "special paste" or "advanced paste" ---------------------------------------------------------------------- rvk · 2025-12-18 09:55 Quote from: Martin_fr on December 18, 2025, 10:51:47 amAnd, yes, IMHO the name "multipaste" is not the best. Well it represents what it does (if you read "multi" as short for "multiline"), and maybe its my lack of wide enough knowledge, but most other apps that I know have this as "special paste" or "advanced paste" It's the exact same name (and even exact same dialog window) as Delphi has. So it should be obvious enough ---------------------------------------------------------------------- paweld · 2025-12-18 10:17 I use the following solution: https://forum.lazarus.freepascal.org/ind ex.php/topic,64695.msg492116.html#msg492116 But read through the whole thread, there are other ideas there too. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 10:32 Quote from: PizzaProgram on December 18, 2025, 08:58:21 am(... So I do not have to put: ' signs at the beginning + end, plus add Line breaks 20-40 times for each line.)  Just realized, there are 2 ways to interpret that. 1) "I do not have to" => you don't want the work to put all the quotes into the source. You want the IDE to do that for you 2) You don't want the result of that. I.e., you do not want such an amount of quotes to be in your source (never mind how they were produced). If it is the 2nd, then yes: See the other thread, and maybe use resources. On the long run, FPC 3.4 should have multiline string. So you can open one quote, add any text with line breaks and close one quote. But FPC 3.4 is not yet in reach. ---------------------------------------------------------------------- rvk · 2025-12-18 10:39 Quote from: Martin_fr on December 18, 2025, 11:32:25 am1) "I do not have to" => you don't want the work to put all the quotes into the source. You want the IDE to do that for you 2) You don't want the result of that. I.e., you do not want such an amount of quotes to be in your source (never mind how they were produced). Seeing the opening post (where the "convert to {}" is mentioned and missing such in FPC) it's option 1. Quote from: PizzaProgram on December 18, 2025, 08:58:21 amSo I wonder:  - Why are there so many other "convert to {} , etc" context editing functions,  - but this basic one is still missing after so many years of development? But... it's not missing ---------------------------------------------------------------------- Martin_fr · 2025-12-18 10:43 Quote from: rvk on December 18, 2025, 11:39:28 amBut... it's not missing  Well, it's not "convert". Convert would be if it takes text already in the editor. But it does the job, if you are willing to copy/cut the text first, and then paste it. ---------------------------------------------------------------------- DomingoGP · 2025-12-18 13:09 I use a Pascal script macro to do it. The macro convert the selected text to a Pascal string. Useful when dealing with  SQL queries  or OpenGL shaders. https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSelec tionToString.txt Requires pascal script enabled. ---------------------------------------------------------------------- Nicole · 2025-12-18 14:09 There is a nice thing working with all text: sLineBreak; s:='You will need it often:' + slinebreak + 'May be you remember "sLinebreak" and not keep mixing up #13#10 and #10#13"' + linebreak + linebreak + 'Enjoy!'; ShowMessage(s); ---------------------------------------------------------------------- PizzaProgram · 2025-12-24 05:24 Thanks You very much for all the solutions! Marry Christmas to ALL of You!  (Sorry I had not time to answer sooner, but I had a deadline until Christmas. Which I've succeeded! )    1. I've never have thought that it could be solved with Edit>Multiline  ("cut first", paste it back ... ) 1.1. Especially because it is translated to my local language (hu) as "Beillesztés forráskóddal ..."  = which could be translated back to English as: "Paste with source code ..." 1.2. IMHO the "Beillesztés mint ..." = "Paste as ..." would be a better naming for that menu. 2. Yes, I had 25 years long used a separate little EXE to do the job, which I've wrote to myself (in D7), having 2 text boxes + 1 button which already copied to the clipboard the result. (... but this time I did not have it at my hand, because I'm developing on a remote secured Win-VPS via RDP.)   3. Those, who are developing Lazarus IDE, please consider to:    - Add +1 line under the context menu [Source]: '  Convert to '...'+sLineBreak+ (put spaces before/after + sign, if it is set so. 'string' + sLineBreak +)  That's where I was (logically) searched first. (and +3x after, if I might have missed something)  4. While I like the idea that the new FPC will be able to handle multiline strings at the source, that would mean we'll loose intention (="TABulation") of the code. Personally I always disliked it in other programming languages. Makes very hard to see where the real code starts or ends.   PS.: Edited Subject as [SOLVED] ... ---------------------------------------------------------------------- dseligo · 2025-12-24 10:01 Quote from: PizzaProgram on December 24, 2025, 06:24:52 am2. Yes, I had 25 years long used a separate little EXE to do the job, which I've wrote to myself (in D7), having 2 text boxes + 1 button which already copied to the clipboard the result. I also have similar program (but not for that long ). Only my program have one more button: it's purpose is to make clear SQL when from source, so it works in both ways. ---------------------------------------------------------------------- Martin_fr · 2025-12-24 10:04 Quote from: PizzaProgram on December 24, 2025, 06:24:52 am3. Those, who are developing Lazarus IDE, please consider to:    - Add +1 line under the context menu [Source]: '  Convert to '...'+sLineBreak+ (put spaces before/after + sign, if it is set so. 'string' + sLineBreak +)  Please add as a feature request "Convert selected text to quoted string". Same as "Multipaste...", just work on text already in editor.