Copy/Paset with VSCode and Putty

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
mc2software
Posts: 5
Joined: Wed Jan 13, 2021 6:08 pm
Location: Northern Florida

Copy/Paset with VSCode and Putty

Post by mc2software » Thu Feb 18, 2021 9:50 pm

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.

User avatar
Roberthh
Posts: 2462
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Copy/Paset with VSCode and Putty

Post by Roberthh » Fri Feb 19, 2021 8:10 am

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.

mc2software
Posts: 5
Joined: Wed Jan 13, 2021 6:08 pm
Location: Northern Florida

Re: Copy/Paset with VSCode and Putty

Post by mc2software » Fri Feb 19, 2021 6:06 pm

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.

Post Reply