3

Using multiple versions of Mathematica and Linux I have encountered a bug that extra spaces are introduced when copying parts of strings containing for example underscores. For example, selecting 1_2_3, copying it, and pasting it will produce 1_ 2_ 3.(I reported this bug and it was confirmed as a bug by tech support).

Is there a work around for this?

Kvothe
  • 4,419
  • 9
  • 28

1 Answers1

3

I added the following MenuItem to MenuSetup.tr that performs a copy, cleans up the clipboard and puts it back in the clipboard clean.

MenuItem["Copy2", 
    KernelExecute[FrontEndTokenExecute[InputNotebook[], "Copy"];    
      CopyToClipboard[ReplaceRepeated[Part[NotebookGet[ClipboardNotebook[]], 1, 1, 1, 1], 
          RuleDelayed[RowBox[List[Pattern[str, BlankSequence[String]]]], StringJoin[str]]]]],
             MenuKey["C", Modifiers->{"Control", "Shift"}], Rule[MenuEvaluator, Automatic]],

(I chose to replace the plain copy MenuKey (removing that one) since I didn't regularly use it but you can of course assign it to any key.)

This seems to work for the cases I tried but it might not be robust for copying and cleaning up everything.

Kvothe
  • 4,419
  • 9
  • 28