Copy, pasting, duplicating is actually part of programming. It saves our time and makes the development process easy and short. In this article, we are going to show you that how you can duplicate any line in most of the code editor.
How to make a duplicate line in code editors
First, select a line or multiple lines you want to duplicate. Then you have to use a keyboard shortcut. Here is the table of keyboard shortcut:
Operating systems | Keyboard Shortcut |
Windows | Ctrl + D |
Mac | Command + D |
Linux | Ctrl + D |
For example, if you are a Windows user then press the Ctrl and D keys at the same time. Before applying this you must have to select the block of code or line of code you want to duplicate. This works in Notepad ++, Android studio too. Press Alt, Shift, F keys at the same time to format the code. Here is an article about code formatting in VS Code.
When we need this
Suppose you are building a simple gallery using HTML and CSS. After creating the first row you can duplicate that row again and again. Because the code is the same for every row. You just have to change the image location to change the image. Ctrl + D method helps us in those cases.