문제

Does anyone else experience this? If I want to paste code from OneNote2010 it does simply not work.

Reproduction: Create any WPF app, copy the XAML into OneNote2010, copy it back -> Whitespace issues.

Or use this sample:

<Popup Placement="Center" IsOpen="{Binding Error, Converter={StaticResource StringBoolConverter}}" PopupAnimation="Slide">
        <userControls:ErrorMessageControl></userControls:ErrorMessageControl>
    </Popup>

After putting it into OneNote and copying it back it gets broken. I can't even paste it here as it never gets displayed.

Pasting it in XAML creates messages like

Error 1 " " is not valid in a name. MainWindow.xaml 94

Error 2 White space is missing. MainWindow.xaml 94

Seems like many whitespaces are odd for the editor.

I've compared the pasted code in Notepad++ and displayed non printable characters and I do not to see any issues with the whitespaces.

도움이 되었습니까?

해결책

Set paste option to "Text Only" when pasting into OneNote.

When pasting, open the menu and select "Text Only"; then open the menu again and set it as default paste.

Paste Options with "Set as default" highlighted

If the menu is not shown when pasting, go to File -> Options -> Advanced, then in "Editing" group make sure that "Show Paste Options button when content is pasted" is checked.

다른 팁

Also if you want to save formatting, you may use a workaround:

  1. Paste text to the GoogleDocuments first
  2. Copy this text
  3. Paste to the OneNote

Good luck. If someone knows better solution - please share it.

The problem is that OneNote seems to be replacing spaces with non-breaking spaces (see https://en.wikipedia.org/wiki/Non-breaking_space) which is a different character.

I came up with this solution adding a script in AutoHotKey https://autohotkey.com

#Persistent
return

OnClipboardChange:
 if WinActive("ahk_exe ONENOTE.EXE")
 {
   nbs:=chr(160)
   StringReplace, Clipboard, Clipboard, %nbs%, %A_SPACE%, All  
 }
return

This is what it does: If AutoHotKey detects a clipboard change (for example you copied text from OneNote) and the active window is onenote.exe, then all non-breaking spaces (char 160 decimal) are replaced with normal spaces.

Using Samuel's comment in the XAMeLi's response I was able to resolve this using Notepad++. Here's how:

  1. Open the file (in my case it's a SQL file. You can actually see the goofy non-breaking spaces in SSMS) using Notepad++.
  2. Open the "Converter" plugin by Don Ho (really?), "Conversion Panel" menu item.
  3. Go to the "Hexadecimal" textbox and type "A0". To the right of the "Ascii" textbox hit the "Copy" button.
  4. In Notepad hit Ctrl-H to "Find and Replace". In the "Find" textbox hit CTRL-V to paste in your ASCII code there.
  5. Go back to the Conversion Panel. Type "20" into the "Hexadecimal" textbox. Again hit the "Copy" button to the right of the "ASCII" textbox. Go back to your Find/Replace dialog and click on the "Replace" textbox. Hit CTRL-V to paste the space there (you probably could get away with just hitting the spacebar but I'm taking no chances here). Make sure "Match whole word only" is turned OFF. Hit the "Replace All" button

Your text should be repaired. Copy it all, then paste it back into your VS editor and try to build.

...an impromptu solution could be to select one of the non-breaking spaces in SQL studio editor and search and replace them all with a space.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top