Paste lines separately - split clip
Hello, how can I split clip to multiple clips eg. by linebreak. Let's say you copy list of something, but you need to paste it separately line-by-line. O you copy excel column and you need to fill some form with separate cells values. I think that it's a pretty common usecase, but I can not find a way how to do that with Ditto.
Is there some way how to extend Ditto by custom macros or something similar?
Anyway, thank you for a wonderful app :)
I've created a quick small utility in PowerShell to do that, but it will be better to have this directly inside Ditto
$text = Get-Clipboard
$lines = $text -split "(`n|\t)"
$lines = $lines.ForEach({ $_.Trim() })
foreach( $line in $lines ){
if( $line ){
Set-Clipboard -Value $line
Start-Sleep -Milliseconds 60
}
}
* to make this works you need to set proper delays in Advanced settings in Ditto
Hi @kubiqsk,
Glad to find another PowerShell user here on Ditto Issues. I consider both Ditto and PowerShell to be invaluable tools for user productivity.
That's why a few months ago I raised an issue requesting the addition of PowerShell support in Ditto: [RFE] Add support for writing scripts in C# and PowerShell
I suggest you take a look at it and if you agree give it a thumbs up 👍. Maybe with enough support, we can get @sabrogden to consider the proposal.
Best regards, Claudio
Hi @claudio-salvio, ok, sure, thumb is there ;)
@kubiqsk: Please indicate which version is affected and provide an example.
@Chealer affected by what? I'm not sure if I understand your question.
This is a missing feature.
I think that everything is well explained in my post, or not?
Ok, another example / explanation:
Someone send you some details that you need to fill into some form, but you don't want to copy them one by one, line by line... instead you should be able to copy whole list or excel column and then split your clipboard item / record in Ditto into separate ones, so you can paste these lines one by one...
One text:
aaa
bbb
cccc
will split into 3 items that you can paste separately
aaa
bbb
ccc
That's exactly what I've achieved with PowerShell script, but it would be much better to have this directly in Ditto :)
@kubiqsk: Oh, I think I see. You are asking a question, but this is an ITS, so entries are supposed to be issue reports.
To the best of my knowledge, Ditto 3.25.96 has no solution to your problem. Do you really want a variant of the copy function which creates one clip entry per line? Or would being prompted about which line to paste when you paste multiline clips not suffice?
It can be right-click option on clip eg. "Split by lines"... or even better "Split by regexp"...
Or it would be great to support custom scripts in general, like @claudio-salvio mentioned above... There are many other use-cases that can be solved by users individually for their needs by a few lines of code, so some plugin / addon / extension / module system ideally with some powerful syntax language that allows you to do interesting things, so imho PowerShell is ideal, but also C (|++|#) is acceptable...
@Chealer and ofc you don't want to run this each time you copy something, so we need to be able to extend right-click menu or trigger this scripts by some shortcut...
Currently I have .ps1 file on my desktop that I will run when I need to split clipboard to separate lines and it's working fine, but I can imagine much better way :) and I think many people would appreciate possibility to split copied text directly in Ditto before pasting... even some comma separated things, etc...
@kubiqsk: C is a low-level language. Ditto’s scripting uses ChaiScript.
So if I understand correctly, you are proposing a "Split" feature which would create new clip entries? So in the example you provided, if you wanted to paste "bbb", you would:
- Copy the text
- Open Ditto
- Use "Split (line by line)" on the latest entry
- Press Ctrl+2
That would satisfy your request?
License
This comment and any other from myself on this ticket is offered under the terms of CC0 1.0.
@Chealer I remember I've tried to write this in ChaiScript but without success, but still, I think that ChaiScript will run each time you copy or paste something or not? That would be a problem...
Yes, I can imagine something like this

that could maybe open some popup with text field where you can specify regexp, because you may want to split it by new line, or comma, or anything else...

then I have also a few additional ideas for that popup with regexp field:
- checkbox to reverse split order
- checkbox to remove original clip from memory
but that's maybe not needed at all...
@Chealer I remember I've tried to write this in ChaiScript but without success, but still, I think that ChaiScript will run each time you copy or paste something or not?
Well, that depends on how ChaiScript is used. I have not used Ditto’s scripting, but if I understand ticket #84 (the screenshots in the "configuration details" accordion) and the comment from sabrogden in ticket #328 correctly (and I may misunderstand), a custom script only runs when specifically invoked, via the Special Paste sub-menu.
Thank you for the proposal @kubiqsk
I do not remember ever thinking about the feature you requested, but it sounds like it might be useful. However, what would be way more useful to me would be an advanced paste which lets me edit the clip before pasting it. It would be great if in the example you provided, I would get a prompt, could remove the first line, add <strong> before, add </strong> after, remove the last line, and end up pasting "bbb" in bold when I would press, say Ctrl+Enter.
To reformulate this as a report, this should be retitled. I suggest:
Pasting only certain lines from a clip entry is time-consuming (please add "Split clip")