Page 1 of 1

Copy/Paset with VSCode and Putty

Posted: Thu Feb 18, 2021 9:50 pm
by mc2software
I've been having an odd issue with Putty and VSCode when copy/paste is used from VSCode to a terminal window. Whenever I paste indented code, the terminal adds additional spaces for each line. For example, if it looks like this in VSCode:

Code: Select all

for i in range(0, len(switchPins)):
    buttons.append(Pin(switchPins[i],Pin.IN))
    buttonState.append(0)
It gets pasted like this in the terminal window:

Code: Select all

for i in range(0, len(switchPins)):
	buttons.append(Pin(switchPins[i],Pin.IN))
    		buttonState.append(0)

This obviously leads to a "unexpected indent" error.

The only terminal I had that worked was Pymakr, in the command window inside VSCode. But Pymakr has stopped working and I was having so many other issues with it that I uninstalled it. I've tried Putty and the uPyCraft terminal and both have the same issue. I'm thinking that it has something to do with a LF/CR difference, and I'm convinced it's how VSCode is copying the text, but I'm not sure how to work around that.

Re: Copy/Paset with VSCode and Putty

Posted: Fri Feb 19, 2021 8:10 am
by Roberthh
Switch in REPL to paste mode with Ctrl-E, paste, and the switch back with Ctrl-D. It is the REPL autoindent which causes the effect.

Re: Copy/Paset with VSCode and Putty

Posted: Fri Feb 19, 2021 6:06 pm
by mc2software
Thanks! Can't believe I couldn't find the article on the Copy/Paste mode in the documentation. Really hope the Pymakr issues can be resolved.