Nano Editor looses characters in copy/paste

0

I am using terminal mode in two Linux machines using Ubuntu 18.04. On my laptop I navigate with a touchpad equipped with a left and right select button. I have a file on first machine that I want to copy to the second machine. I have tried successfully using scp to copy the file from first machine to second machine. I have also tried cat file on first machine, Ctrl-C select/copy then on second machine I open nano editor and I do a right click from the touchpad and the contents are copied. All selected content seems to copy fine, both scp and Ctrl-C except for the remarks with multiple same characters. For example:

#########################################
//------------------------------------------

are copied over as:

#
//-

Respectively It doesn't seem to affect the running code and in .c files gcc works just fine. However, if I try to edit the copied code nano editor acts strangely like the characters are hidden, they will show then become hidden, etc. as I try to delete and edit them including Ctrl-k in nano editor. Is there a work-around or is this even considered an issue. I have searched around but don't see anything related to multiple characters issues. Thanks for input.

WesZ

Posted 2019-12-01T15:35:52.730

Reputation: 1

So what is your question? Do you want to copy a file from machine A to machine B? That is what I read. And you seem to get into trouble doing that, and now try to fix it via copy/paste. That is not the way to do this. If you want to copy a file, try rsync. – SPRBRN – 2019-12-01T15:42:16.587

Is Nano running with syntax highlighting? – Michael Harvey – 2019-12-01T19:57:43.690

Hello SPRBRN, sorry for the confusion. My question is, what can I do to prevent those characters from disappearing. I can copy the whole file from A to B using scp, I have no problem doing that. What I am concerned with is that after the file copy or even after a copy/paste those characters using nano editor are shortened or missing. If I cat the copied or pasted file cat shows the characters are there. It's that nano editor does not recognize them. – WesZ – 2019-12-02T11:20:07.633

Hello Michael. Yes nano editor is using syntax highlighting. – WesZ – 2019-12-02T11:23:03.893

There are many places where the characters could be lost. There are tools to check the clipboard contents on all relevant machines. – xenoid – 2019-12-02T12:52:22.413

Hello xenoid, The characters are there. They are visible with the "cat" command. They are not visible with the Nano editor. They are also visible with the vi editor. – WesZ – 2019-12-02T14:06:00.453

When Nano is running with syntax highlighting, some text is hard to see unless you have certain background colours, including black. You can toggle syntax highlighting on/off with Alt + Y keys, or by running nano with the -Ynone option. – Michael Harvey – 2019-12-02T20:27:22.730

Thanks Michael, that was a great idea to run nano without highlighting. However without highlighting, the characters are still missing. But if I take the cursor and place it at col 1then just use the right arrow key, as the cursor passes over the characters they reappear. I am not typing, just moving the cursor across the columns. I can also use the end key and the cursor will move to the last character location (col 81) but no characters will appear. They only appear if the cursor travels across them. – WesZ – 2019-12-03T10:00:54.880

When you say 'terminal mode' do you mean an actual terminal login, or one of the Alt + F key terminals? That is, not a GUI terminal window? Also, are these 'hidden' characters normal text, or are they non-printing characters like \012 \011 \011 etc? If so, see here

– Michael Harvey – 2019-12-07T10:39:04.013

Hi Michael, I actually SSH into the machine using PuTTY. That's what I mean Terminal Mode. It is not a GUI window. They are normal text as shown above. ##### and //----- and I've even tried #aaaaaa and get #a. Using Cat shows the characters. Nano ignores the second and on characters if they are the same character that repeats itself. – WesZ – 2019-12-07T11:20:23.620

Hello, I've done some more testing with other machines at my disposal and to make a long story short, I can take a file on Ubuntu 16.04 nano 2.5.3 and copy that file to a Ubuntu 18.04 nano 2.9.3 and have the missing characters issue. I can then take that exact file that I copied to the Ubuntu 18.04 nano 2.9.3 and copy the file to a completely different 16.04 machine with 2.5.3 and the file displays just fine. If I create a file on 18.04 with 2.9.3 with the repetitive characters then save that file and reopen it on the same machine the characters are missing. This is clearly a nano issue. – WesZ – 2019-12-07T12:32:02.840

So you're using PuTTY. I have almost completely abandoned that app in favour of the WSL console on Windows 10. Perhaps you may have an issue of interaction between some Nano versions and the PuTTY terminal type setting. You could try export TERM=xterm-color on the remote hosts (e.g. in .bashrc). – Michael Harvey – 2019-12-07T15:00:13.707

Answers

0

Well after much ado and even filing a bug report at nano base headquarters, the fix was as simple as updating PuTTy on my Windows laptop from PuTTy version .7 to version .73. I thought for sure it was a nano problem, it was platform dependent, repeatable across different machines, exclusive to nano - other editors and viewers worked fine... So I learned a few things with this problem, as simple as this fix was...it wasn't so much for me. I wanted to post the fix here just in case some other chap falls into this trap :) Thanks for your help Michael Harvey and others.

WesZ

Posted 2019-12-01T15:35:52.730

Reputation: 1