inserting blank lines between selected text

Share your favorite FastKeys commands
Post Reply
User avatar
travibe
Posts: 4
Joined: Nov 2nd, ’20, 23:29

Post by travibe » Jan 5th, ’21, 00:27

I'm curious to see if there's any way to create a script or some other kind of command for fast keys that would transform the following example

xxxxxxxxxxx
yyyyyyyyyyy
zzzzzzzzzzzz

Into

xxxxxxxxxxx

yyyyyyyyyyy

zzzzzzzzzzzz

essentially, all I'm looking for is to add an extra blank line after each existing line of text. It would also be awesome if there was a way to remove extra blank lines as well! Thanks to anyone who takes the time to read this and/or create a script.
User avatar
Marko
Posts: 1257
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 5th, ’21, 14:15

It is possible, of course. Where is the original text coming from?
User avatar
travibe
Posts: 4
Joined: Nov 2nd, ’20, 23:29

Post by travibe » Jan 5th, ’21, 14:23

It's going to be primarily text in notepad, word, or I also have a need for it in some programs that have form entry boxes that are populated with text. It doesn't bother me so much if I have to copy the text from the form into a word editor like notepad or word prior to running the script on it but would be ultra convenient if I could just do it within the dialog box itself. The immediate need for this script right now is qbittorrent edit tracker dialog box where I'd like to highlight all the listed trackers for a torrent and be able to separate the listed trackers with blank lines so that the program looks at each tracker in its own tier and not grouped together like it does by default. But I have needed this for other purposes as well
User avatar
Marko
Posts: 1257
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 5th, ’21, 17:55

This will paste the clipboard content with removed blank lines.
Set it as a shortcut, Type: Command.

Code: Select all

string:=Clipboard
Loop
{
    StringReplace, string, string, `r`n`r`n, `r`n, UseErrorLevel
    if (ErrorLevel=0)
        break
}
Send, % string
string:=""
User avatar
travibe
Posts: 4
Joined: Nov 2nd, ’20, 23:29

Post by travibe » Jan 5th, ’21, 19:43

thank you so much for that. I will try it out immediately! Would the code to insert an extra line between lines of text be something similar?
User avatar
Marko
Posts: 1257
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 5th, ’21, 21:15

Sorry, this should insert blank lines.

Code: Select all

string:=Clipboard
StringReplace, String, String, `r`n, `n`n, all
send, % string
string:=""
User avatar
travibe
Posts: 4
Joined: Nov 2nd, ’20, 23:29

Post by travibe » Jan 10th, ’21, 15:06

Marko thank you so much for your time and energy that you invested in putting together this script for me. I tried your Creations and the one you gave me that inserts additional lines works like a charm. However, the one that is intended to remove extra lines does not appear to be doing that. I think it's actually doing a remarkable job at what I was asking for with inserting the extra lines… This was beautiful and that it only added one extra line to the lines that did not have an extra line between them already which is what I was hoping for but lucked out and got In a roundabout way. The script doesn't appear to remove any extra lines from what I can tell. Am I doing something wrong? I set up the shortcut as a command like you said.
User avatar
Marko
Posts: 1257
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 10th, ’21, 18:02

Sorry, I don't follow. Give me a simple example of what you would like to achieve. ;)
I also removed part of your post as it contained links.
Post Reply