Issue #21 (Lines of Code Shortcuts)09/14/22
|
Get a weekly dose of tools, articles, and other resources covering remote work, productivity, career well-being, and lots more.
|
|
|
There are a few interesting keyboard shortcuts for dealing with lines of code that I haven't use much at all and often forget that they exist. These shortcuts aren't necessarily specific to VS Code, but I thought you might find them useful.
DELETE A LINE
First of all, if you're going to delete an entire line, it's common to select the entire line and then hit delete. But a quick way to delete a line is:
- Put your cursor anywhere in the line you want to delete
- CTRL/CMD+SHIFT+K
COPY A LINE UP OR DOWN
Here's one that's probably more useful: To duplicate, or copy, a line:
- Put your cursor anywhere in the line you want to duplicate
- ALT/OPT+SHIFT+Down Arrow (to duplicate below the line) or ALT/OPT+SHIFT+Up Arrow (to duplicate above the line)
CUT, COPY, PASTE WITH NO SELECTION
Another potentially useful one is when cutting, copying, and pasting lines of code. Normally when you want to cut/copy and paste an entire line, you would select it first, then use the usual keyboard shortcuts for copy and paste. But you don't have to do that. You can cut, copy and paste any line of code with the cursor anywhere in the line.
In the process of pasting lines in this way, it's also useful to know that you don't have to be at the start or end of a line. You can have your cursor anywhere inside the line of code and the paste operation will paste above the current line. Of course, it's different if you selected and copied some arbitrary text. In that case, paste would work as expected, and you'd paste right where the cursor is.
MOVE A LINE UP OR DOWN
Finally another one that you might find useful is moving the current line either up or down a line. You can do this using ALT/OPT-Up Arrow or ALT/OPT-Down Arrow. This will move the entire line in the chosen direction and essentially swap it with the one either above or below.
Now on to this week's hand-picked links!
|
|
|
VS Code Tools
|
VSCode Working Memory — VS Code extension that allows you to open a single text or markdown file without leaving VS Code, to quickly capture notes, ideas, snippets, etc.
AWS Toolkit — A popular VS Code extension that makes it easier to develop, debug locally, and deploy serverless applications that use Amazon Web Services (AWS).
Image Preview — A VS Code extension that adds an image preview that appears in the gutter on hover, for image URLs found in your code.
XML Tools — This VS Code extension hasn't been updated in a few years, but it's extremely popular (almost 4 million installs). It provides XML Formatting, XQuery, and XPath Tools for VS Code.
|
|
|