Pasting Clipboard to File with LF (not CRLF)?

Is it, or would it be possible to paste from the clipboard to a file with LF (\n) line endings instead of CRLFs (\r\n)? I'm able to set the file encoding, but not the line endings, which would be useful for files that get transferred to my VPS / USB stick for my Linux machine. It's mostly annoying when viewing the files in the terminal where the last line of the file and the prompt can be concatenated.

Thanks!

- Directory Opus v12.23.4 Beta x64 Build 7769
- Windows 10 v20H2 OS Build 19042.906

I think you'll get whatever is in the clipboard, so if the clipboard has CRLF, the result will.

There isn't a built-in setting to convert line endings for clipboard pastes, but you could do it via scripting.

I'll have to look into it, thanks.

By the way, I'm not sure if you're aware but certain links in the local 127.0.0.1 Help don't work: The "Scripting" link points to javascript:TL_576857.HHClick() which only does anything on the online version of the help. I've not come across other instances, but they may be present.

Thanks for the heads up! We found 95 such links throughout the manual. Will be fixed in the next update.

1 Like

This is what I came up with if anyone is interested:

// Convert CRLFs to LFs and encode as UTF-8 (without BOM)
function OnClick(clickData) {
    if (DOpus.GetClipFormat == '') {
        var paste_type = 'Image';
    }
    
    if (DOpus.GetClipFormat == 'text') {
        var paste_type = 'Text';
        
        var clip = DOpus.GetClip('text');
        var regex_pattern = /\r\n/gi;
        var lf_clip = clip.replace(regex_pattern,'\n');
        
        DOpus.SetClip(lf_clip);
    }
    
    var cmd = clickData.func.command;
    cmd.RunCommand('clipboard paste=enc:utf8nobom as=ask:{date|yyyyMMdd}_Clipboard_' + paste_type);
}
1 Like