DEV Community

Cover image for 5 Copy and Pasting Tips that Every Developer Should Know
songthamtung
songthamtung

Posted on

30 3

5 Copy and Pasting Tips that Every Developer Should Know

Work Smarter, Not Harder.

If I knew about these coding tricks earlier in my career, it would have saved me sooo much time. Here are 5 advanced copy and pasting tips that you can use to work smarter and more efficiently.

You can follow along with the sample dataset below, or better yet, try it with your own data. FYI— I’m using Mac and Visual Studio Code, but feel free to use other OS and text editors.

Sample dataset

48 Laws of Power - Robert Greene
Be Here Now - Ram Dass
Extreme Ownership - Jocko Willink and Leif Babin
How to Eat - Thich Nhat Hanh
How to Win Friends & Influence People - Dale Carnegie
Radical Focus - Christina Wodtke
ReWork - Jason Fried & David Hansson
Sapiens - Yuval Noah Harari
Shantaram - Gregory David Roberts
Soft Skills - John Sonmez
Tao of Wu - RZA
The Alchemist - Paulo Coelho
The Art of War - Sun Tzu
The Book of Mistakes - Skip Prichard
The Culture Code - Daniel Coyle
The Four Agreements - Don Miguel Ruiz
view raw booklist.txt hosted with ❤ by GitHub

1. Vertical selection

My objective is to add the <li> tag in front of every row. Instead of doing it the old fashion way of copy and pasting multiple times, I do it once with the help of vertical selection.

Vertical Selection
Vertical Selection Example

hold shift + option + cmd + arrow direction
Enter fullscreen mode Exit fullscreen mode

2. Adding value to the start of every row

Another way to add value to the start of every row is by using regex (.*). This is built into most text editors and can be found in the find feature.

Regex or regular expression is a sequence of characters that define a search pattern.

Regex Start
Use regex to add value at the beginning of each row

1. Open Find and Replace
2. Enable regex .*
3. Enter ^ in Find
4. Enter value in replace
5. Execute
Enter fullscreen mode Exit fullscreen mode

3. Adding value to the end of every row

What if I want to add the closing tag at the end of every row? To do so, I would also use regex, but with a different search pattern.

Regex End
Use regex to add value at the end of each row

1. Open Find and Replace
2. Enable regex .*
3. Enter $ in Find
4. Enter value in replace
5. Execute
Enter fullscreen mode Exit fullscreen mode

4. Shifting rows without highlighting and dragging

What happens if I want to quickly rearrange my data? Again, I can use the traditional cut and paste or highlighting and dragging with the mouse... but there is a faster way.

Rearrange Rows
Quickly rearrange your rows

hold option + arrow direction
Enter fullscreen mode Exit fullscreen mode

5. Copy and pasting without copy and pasting

This last tip is one of my favorites. Instead of copy and pasting and entering new lines in between, I can quickly duplicate the values with a simple shortcut key.

Copy and paste
Quickly duplicate your lines

hold shift + option + arrow direction
Enter fullscreen mode Exit fullscreen mode

Wrapping up

Copy and pasting stuff is great. Regex and advanced keyboard shortcuts takes it to another level. Have another tip for coders to increase productivity? Leave a comment below.

Remember folks: work smarter, not harder.

Thanks for reading! Originally posted on The Startup.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (7)

Collapse
 
nareshravlani profile image
nareshravlani

Nice tips ! Loved the 3rd point.
You can also mention a visual studio trick where you can paste data from your clipboard history. Simply press cntrl + shift + V and you can access your visaul studio clipboard history.

Collapse
 
songthamtung profile image
songthamtung

Thanks for reading nareshravlani!

I tried using cntrl + shift + V, but it doesn't work for me! Perhaps it's a windows thing?

Collapse
 
nareshravlani profile image
nareshravlani

Oh yes, it works on windows!

Collapse
 
zeslova profile image
Simon Newby

Comments from someone on Win10/VS2017:
1) Shift + Alt works here (regardless of where you are in the line)
I couldn't replicate 4) and 5) at this time, but there is likely something I'm missing.

Collapse
 
sc7639 profile image
Scott Crossan

I think 4) might be alt+shift+arrow direction and 5) might be ctrl+shift+D but that might have been my personal key layout

Collapse
 
songthamtung profile image
songthamtung

Thanks for reading and sharing your OS/text editor Simon!

Not sure what the hot keys are for 4) and 5) since Im using Mac. It's probably a combination with ctrl, alt, shift, and arrow directions. Perhaps a windows user can point us in the right direction?

Collapse
 
he_flower_172d57d7dc438b1 profile image
he flower

can u make it copy and paste so i can paste it on my vscode****

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs