vsCode Multi-Line Copy & Paste in Same Line

I just stumbled into this today and it is extremely helpful when editing HTML or JSON in vsCode.

I was editing a NetSuite Advanced Transaction Template which is written in Freemarker. There is no interactive debugging of templates in NetSuite, so I wanted to show variables as part of the page. I wanted variable names, followed by the variable’s value. Here’s how easy this was, and I hope this makes it easy to see other uses for the multi-line copy and paste functionality in vsCode.

First, here is how it works. Then I’ll share the keystrokes.

  • First, I pasted in the variables. I actually used the same multi-line edit capabilities to create the list from Freemarker <#assign> statements higher up in the page.
  • [ctl] + [alt] + [shift] to select the lines for multi-edit. Of course you [down arrow] to include multiple lines.
  • [home] to move to the beginning of each line.
  • [shift] + [end] to highlight the entire line.
  • [ctl] + c to copy within the line.
  • [end] to jump to the end of the line on all lines
  • I typed “: ${“, which completed the brackets and left the cursor in between brackets.
  • [ctl] + v to paste the duplicate variable names
  • [end] to jump to the end of each line
  • I typed “<br />”

I could see this being extremely handy when creating arrays of JSONized objects in JavaScript, or tables in HTML. I hope this helps all my fellow lazy typists to spend more time writing code and less time formatting code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s