Image

Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

How do I type something different at each cursor when using multi-cursor editing in VS Code?

+4
−0

For example, say I have this CSS:

.ocean {}
.land {}
.sky {}

I want to give each of them a background-color, so I use multi-cursors and type:

.ocean { background-color: }
.land { background-color: }
.sky { background-color: }

Now how do I type a different colour for each one? Say blue, green, lightblue.

I would love to have a keybinding to rotate through the cursors and type one colour at a time, then go right back to multi-cursor editing so I could add the trailing semicolon and more CSS declarations inside each block.

The best workaround I've found is to open a text file and type one item per line, then copy-paste it into the CSS. Thankfully multi-cursors handles this correctly.

blue
green
lightblue

Note: This is based on this Stack Overflow question, but more specific (not a sequence of numbers, and not about Sublime). I'll post my own answer here shortly.

History

0 comment threads

2 answers

+3
−0

Use the extension Insert Sequences. You just run the command Insert Sequences (extension.insertseq), then type what you want in square brackets, separated by commas:

[blue, green, lightblue]

This extension can also do other things like insert ranges of numbers and letters, with optional formatting. The default is to insert numbers, one for each cursor.

Note: I also posted this solution on Stack Overflow.

History

0 comment threads

+0
−3

You click on the first place and type blue. Then you click on the second place and type green. Then you click on the third place and type lightblue.

Multi-cursors are useful when you are typing the same thing in several places. If you are not typing the same thing, you don't have to use them.

History

0 comment threads

Sign up to answer this question »