More multiple cursor magic 🪄

  Рет қаралды 788,730

Visual Studio Code

Visual Studio Code

2 жыл бұрын

How to add a cursor to every line #shorts

Пікірлер: 561
@TomDoesTech
@TomDoesTech 2 жыл бұрын
The VSCode team thinks of so many thing I didn't even know I needed!
@songokussj4cz
@songokussj4cz 2 жыл бұрын
They do. But in this exact example, this has been there for many, many years. And in Sublime Text years before that. I'm using it for about 8 years now. ST, now VSC. I don't undermine this technique, it's awesome. It's just not new at all. Three more shortcuts I do everyday are "CopyLineDown CTRL+SHIFT+D", AddSelectionToNextFindMatch CTRL+D" and "MoveLineDown/Up CTRL+SHIFT+DownArrow/UpArrow"
@sohn7767
@sohn7767 2 жыл бұрын
@@songokussj4cz and in has been in vi/vim before most of us have been born
@bowiemtl
@bowiemtl 2 жыл бұрын
@@songokussj4cz nobody cares if it’s new or not, just that they are introduced to it
@nevoyu
@nevoyu 2 жыл бұрын
Vim has had this for years before vscode thought of it
@TomDoesTech
@TomDoesTech 2 жыл бұрын
@@nevoyu And the VSCode team bought it to VSCode.
@TinyTiniaMan
@TinyTiniaMan 2 жыл бұрын
VsVim users be like : "Look what they do to mimic a fraction of our power"
@____-pb1lg
@____-pb1lg 2 жыл бұрын
What's VsVim ?
@MrEo89
@MrEo89 2 жыл бұрын
VsVim? Plz. Just go straight to neovim and never look back.
@animeguywithexistentialcri5084
@animeguywithexistentialcri5084 2 жыл бұрын
Haha yeah bro... $GA",^GI" Done.
@notme9801
@notme9801 2 жыл бұрын
@@animeguywithexistentialcri5084 hmm I'll try that. I'm used to doing A,uggVG:norm!.
@animeguywithexistentialcri5084
@animeguywithexistentialcri5084 2 жыл бұрын
@@notme9801hmm... I tried your command strike but I don't get it. I read it like this: -> A = insert mode at end of line -> then hit , (comma) -> = go to normal mode -> ugg = undo and then go to the first line -> VG = visual line mode and go to end of file -> :norm!. (I don't understand this) and then (enter) But it doesn't seem to change anything tho... I'd like to look up for the 'norm' command after this.
@rahulr9539
@rahulr9539 2 жыл бұрын
This project was a huge relief as wordle only allows one game per day. And thank you for mentioning me. ☺
@SahilP2648
@SahilP2648 2 жыл бұрын
I know this video was meant to show off a VSCode feature, but in reality a simple text or CSV file would have been enough to load the list from disk into an array. In python (and similarly JS) it would take no more than 10 lines I think.
@rahulr9539
@rahulr9539 2 жыл бұрын
@@SahilP2648 Loading file is not what's taking all those lines. It is the logic and ui of the game. in python to load json you need 3 lines including import json, with open line, json.load line. In JS it is one line, const array = require('words.json'); for reading from txt in python, 3 lines - with open, file.read, and one line for converting the data to list. And in python reading csv with DictReader or anything else is even worse. Python is easy does not mean other programming languages are not easy to code.
@SahilP2648
@SahilP2648 2 жыл бұрын
@@rahulr9539 yeah I know. I am a developer too lol.
@rahulr9539
@rahulr9539 2 жыл бұрын
@@SahilP2648 😅
@wlockuz4467
@wlockuz4467 2 жыл бұрын
@@rahulr9539 where can I find your video?
@Jakob7539511
@Jakob7539511 2 жыл бұрын
When i need to do this, i usually do a Find+Replace the with ", \t". The cursor strategy might be faster, though. :)
@shichiha6138
@shichiha6138 2 жыл бұрын
Haha, I actually do the same thing!
@vibaked
@vibaked 2 жыл бұрын
You can also use the regex "end of line" operator in your find replace, which is the dollar sign. Replace $ with ", for this example
@kadensharpin2156
@kadensharpin2156 2 жыл бұрын
@@vibaked and don't forget ^ for the start of the line!
@SirCamWA
@SirCamWA 2 жыл бұрын
Regex for everything
@MewKnows
@MewKnows 2 жыл бұрын
I just make a text file with the words separated by a " " and read it and split by " " lol
@wile9763
@wile9763 2 жыл бұрын
Vim version: Press C-v to select columns. Then press I to insert in each column. Or you could just use a Vim macro.
@Plorpoise
@Plorpoise 2 жыл бұрын
I'd use a macro just so I can watch it go through and add all of them. So satisfying :)
@Elwon20
@Elwon20 2 жыл бұрын
:norm was made for this
@imseagull
@imseagull Жыл бұрын
Why do it the hard way when you can write a :g command. Ez pz.
@Gurj101
@Gurj101 Жыл бұрын
@@Plorpoise yup that is fun
@TheSkepticSkwerl
@TheSkepticSkwerl 2 жыл бұрын
Lol. I've just been replacing with ", " ... Regex style
@Jelte_Dijkmans
@Jelte_Dijkmans 10 ай бұрын
Yeah waaaaaaaay easier
@snailedlt
@snailedlt 2 жыл бұрын
Faster and more precise way: 1. Select all -> Ctrl + shift + a 2. Cursor at end of each line -> alt + shift + i 3. Add quote and comma -> ', 4. Move cursor to beginning of each line -> home 5. Add quote -> '
@savantshuia
@savantshuia 2 жыл бұрын
NeoVim/Vim users: "Look What They Need to Mimic a Fraction of Our Power"
@user-fm7uq4fb3f
@user-fm7uq4fb3f 2 жыл бұрын
This is the main reason I fell in love with sublime text years ago. I think I do more multi cursor editing to format things like this than anything else
@GottZ
@GottZ Жыл бұрын
and here I'm sitting just using the neovim extension for this..
@imjulianeral
@imjulianeral 2 жыл бұрын
A few weeks ago I converted a CSV file to an INSERT SQL statement with vscode, these features are a lifesaver
@VezWay007
@VezWay007 2 жыл бұрын
I would've used find & replace " /n" with " ,/n" It's great to see that this is an actual "problem" that other people solves as well and not something stupid I do to myself.
@temmie3325
@temmie3325 2 жыл бұрын
Isn't it easier just to store a file containing all of those and then just read it and then pick a random word from line array?
@JannisAdmek
@JannisAdmek 2 жыл бұрын
I love it. What also works is to replace ^ (regex) with " and $ with ",
@nicholasfinch4087
@nicholasfinch4087 2 жыл бұрын
This is the better way to go. VScode has an upper limit on multiple cursors.
@mikejankowiak5434
@mikejankowiak5434 2 жыл бұрын
Sure that fine and all that's pretty specific. You could just use the replace functionality and use regex to look for every new line that doesn't contain a bracket, then add a comma
@farhanaditya2647
@farhanaditya2647 2 жыл бұрын
That's what I'd do too.
@tinmancode
@tinmancode 2 жыл бұрын
Exactly
@Wylie288
@Wylie288 2 жыл бұрын
that requires knowing regex, pff, who knows that?
@happywednesday6741
@happywednesday6741 2 жыл бұрын
My way is better
@utilyre
@utilyre 2 жыл бұрын
Fun fact: vim has had this feature (in an easier way) since many years ago
@Temax6
@Temax6 2 жыл бұрын
Lol it's hilarious watching videos like these
@farhanaditya2647
@farhanaditya2647 2 жыл бұрын
how?
@Sw3d15h_F1s4
@Sw3d15h_F1s4 2 жыл бұрын
this isn't a new feature in vscode either
@nathanhedglin931
@nathanhedglin931 2 жыл бұрын
Yup.
@KayOScode
@KayOScode 2 жыл бұрын
@@farhanaditya2647 visual mode lets you create a multiline cursor in the same way and macros are even more powerful allowing you to do the same thing without relying on word length being the same
@dgpsf
@dgpsf 2 жыл бұрын
I love VSC’s multiple cursors. you could also use Ruby and just wrap a %w() around the whitespace delimited strings :)
@happywednesday6741
@happywednesday6741 2 жыл бұрын
What I do is put the words without a quote in a csv and then upload this to a sql server and then I write a quick Django app with a list template and just simply copy and paste the results of that once running the app, and then I write all the words out one by one and add quotes to each as I do 👍🏻
@gustavovasconcelos9857
@gustavovasconcelos9857 2 жыл бұрын
I use this feature a lot, it's incredibly helpful
@GavHern
@GavHern 2 жыл бұрын
if your keyboard has one, i recomend using the "home" button instead of using control arrow left. it will place you at the start of each line which is helpful if your list has some mutli-word lines
@IainSimmons
@IainSimmons 2 жыл бұрын
I think the latest version of macOS broke this, home and end go to the start and end of the entire text block, respectively
@dawid0
@dawid0 2 жыл бұрын
@@IainSimmons on mac, you use command+arrow to go to the line start/end, and option+arrow to jump by words
@IainSimmons
@IainSimmons 2 жыл бұрын
@@dawid0 yup, I know. But thanks for sharing!
@robertpietraru1939
@robertpietraru1939 2 жыл бұрын
Or use vim and press 0 or ^
@GavHern
@GavHern 2 жыл бұрын
@@robertpietraru1939 vim and multi cursors has always been an issue for me
@iapplethis
@iapplethis 2 жыл бұрын
I use multicursors everyday, had colleagues that used to message me some files to do some multicursors on 😂
@lemonsavery
@lemonsavery 2 жыл бұрын
This is such a life saver in data formatting
@elyipierre2284
@elyipierre2284 2 жыл бұрын
I wish I new this a few days ago while working on select options 😢
@pmxi
@pmxi 2 жыл бұрын
I had this exact same situation earlier, I was using vim keybindings so what I did was create to macro to do this, it is quite simple. It was also helpful in allowing me to lowercase all the text.
@aidanflynn5392
@aidanflynn5392 2 жыл бұрын
True! Although if you don't want to memorize another shortcut, just: 1. Select the newline at the end of the line 2. CMD+D until all lines are selected 3. Profit
@fred7615
@fred7615 2 жыл бұрын
I had to go into their source code to get that lost for my clone to, I did it in python :)
@floopyy_
@floopyy_ Жыл бұрын
VSCode really pulling off the secret mortal kombat combos here
@rowan404
@rowan404 2 жыл бұрын
I would’ve done ctrl+f and then replace every “ “ with “‘,“ but, honestly, this seems cleaner and more efficient!
@aurinator
@aurinator Жыл бұрын
Keyboard. Efficiency. FTW.
@sanyisasha
@sanyisasha 2 жыл бұрын
What I usually do is moving the items to the left, tab, and then selecting tabs. But the last method is interesting
@demeter1793
@demeter1793 Жыл бұрын
Ctrl+H, match ( \t), replace (, \t) I'm just using the parentheses for clarity, but it also wouldn't matter for the matching if you use regex.
@aayushanand8285
@aayushanand8285 2 жыл бұрын
I've been using this technique for quite a while now...really helpful.. Love it
@Cansyrian
@Cansyrian 2 жыл бұрын
Yesssssss yesssssss thank youuuuu! I thought there was no way to do this ! I really needed to use multiple cursors so many times to organize and edit code ! But it used to take a lot of time ! Now it will take less so thank u!
@kishiue
@kishiue 2 жыл бұрын
You can also wrap the selected text in quotes by just having the text selected and inputing ' or ".
@Radi0actvChickn
@Radi0actvChickn Жыл бұрын
That would just put quotes around the entire thing, not each line
@PanDiaxik
@PanDiaxik 2 жыл бұрын
I prefer the way multiple cursors work in sublime text
@johndon3782
@johndon3782 2 жыл бұрын
Replace > $ for start of lines, ^ for end
@Crunchiest
@Crunchiest 2 жыл бұрын
I needed this, especially to adding quotes and commas to each JSON string. Finally something that helps. Thank you, VSCode Team.
@juliasmith1182
@juliasmith1182 2 жыл бұрын
Can also select the carriage return/line feed character. Beginning of line, shift+back arrow, select all 👍
@rafaelborgesbatista2961
@rafaelborgesbatista2961 2 жыл бұрын
Nice tip! I was needing that a couple of days ago and I did it the slow way
@d4v1dduart38
@d4v1dduart38 Жыл бұрын
Dude I always found your videos very useful thank you for your content
@csharpcoffee
@csharpcoffee 2 жыл бұрын
My personal way is to use Notepad++'s search and replace feature in extended or regex mode (regex only for edge cases and difficult tasks). With extended mode, you can do something like Find: Replace with: " Find: Replace with: ", And voila
@joshuaw1315
@joshuaw1315 Жыл бұрын
API calls: Am I a joke to you?
@SirusStarTV
@SirusStarTV 2 жыл бұрын
There's a lot of string manipulation web tools in "browserling tools", it's nice
@grantpeterson2524
@grantpeterson2524 Жыл бұрын
Lmao, used this for the EXACT same use case when making a Wordle bot about a month ago to add commas
@Wynell
@Wynell 2 жыл бұрын
this is also exactly a very good use case for vim's macros
@xst9880
@xst9880 Жыл бұрын
SSMS has this super handy feature 👍
@adamdavislee
@adamdavislee 2 жыл бұрын
I can't resist the temptation to plug "Kakoune" here! 😄. The following keys would do the trick: % => Select all => Split on lines b => Select previous word i" => Insert quote a" => Append quote % => Select all i[ => Insert bracket a] => Append bracket
@dadestor
@dadestor 2 жыл бұрын
I usually just enter a python interpreter and write a list comprehension for this kind of stuff lmao
@iconsworld9
@iconsworld9 2 жыл бұрын
Big fan of visual studio keep up the awesomeness
@kphk3428
@kphk3428 Жыл бұрын
SublimeText : select all words, Ctrl+Shift+L (to select lines individually), quote, right, comma, space, Suppr.
@peters.social
@peters.social 2 жыл бұрын
that is an awesome feature after having a cursor at each word, why didn't you select the words and place quotes around them, instead of ctrl+left-ing your way to the front to place the second quote?
@skaramicke
@skaramicke Жыл бұрын
That “space” after each word was probably the newline character and not a space.
@MrDicius933
@MrDicius933 2 жыл бұрын
In sublime you can regex replace $(end of line) for commas.
@DarkSolidity
@DarkSolidity Жыл бұрын
Vim users: let me know when something interesting happens...
@goblinslayer5404
@goblinslayer5404 2 жыл бұрын
if u dont know the shortcuts and cant find them, u can just put the words in a text file, and make a loop that updates each line to add the commas
@AssFaceNFT
@AssFaceNFT 2 жыл бұрын
Bloody algorithm always sends you in the right direction 😂🙏🌹
@armadasilque8307
@armadasilque8307 2 жыл бұрын
Oh my god. Oooooh my god. The amOUNT of times I've had to do this manually. Thanks you, god bless you
@askp7104
@askp7104 2 жыл бұрын
Glad I found this when I just started learning
@PomPiDoum
@PomPiDoum 2 жыл бұрын
Thanks !
@pessimistic5579
@pessimistic5579 2 жыл бұрын
Multiple cursors are so useful to learn, i was really annoyed of using regex before i fully learnt this feature
@chongcaleb1131
@chongcaleb1131 2 жыл бұрын
I usually use alt + shift magic with Home and End button, it would be more straight forward 😂
@nftsolboi8321
@nftsolboi8321 Жыл бұрын
I knew about alt+shift+i, but what I needed to know was ctrl+shift+L, so this video was still very helpful for me 😂
@cedric1731
@cedric1731 2 жыл бұрын
I don't know why but I always do some Python magic in cases like this. ^^
@RS-lh4gx
@RS-lh4gx 2 жыл бұрын
***For more specific selections use Middle mouse!!!!!! I use that all the time
@sagshah10
@sagshah10 2 жыл бұрын
I would just use regex find and replace, but you do you mate 😁
@andrewhamel1
@andrewhamel1 2 жыл бұрын
This is exactly what I did making MY world clone. I actually coded the entire thing in something other than VSCODE but realized I needed this functionality so I switched for the remainder of the project 🤣
@sharp_iq6742
@sharp_iq6742 2 жыл бұрын
Find and replace with a small regex with group substitution is faster than all those key binds
@HeyItsMeDave
@HeyItsMeDave 2 жыл бұрын
Time to learn the vim keybindings to do this and much more, easily.
@Alec9821
@Alec9821 2 жыл бұрын
I did a similar thing but it had all words in the dictionary. I had them stored in a database to make the word validation times quicker. Couldn’t really think of a better way. The JS made a XHR to a php API that communicates with the dB.
@rejul008
@rejul008 2 жыл бұрын
I didn't know about it.. thanks for the info
@juni6020
@juni6020 2 жыл бұрын
nice i usually shift alt drag but this is nice
@That_Guy_You_Know
@That_Guy_You_Know 2 жыл бұрын
Instead of arrowing back to the start of the line you can press the home key to do that instantly.
@m77mo65
@m77mo65 2 жыл бұрын
I was looking for this ages ago. I even had to built java program to do this. I'm grateful for this one now.
@athief
@athief Жыл бұрын
Cool and well-know VSCode feature, but I mean you could as well read the file from the URL directly, and save so many lines of code.
@robertchavana3961
@robertchavana3961 2 жыл бұрын
I was ecstatic when i found that feature in atom.
@isaacfink123
@isaacfink123 2 жыл бұрын
Weird I was just building a wordle clone and used this, opened youtube and it was the first suggestion in shorts
@wildcatgerry
@wildcatgerry 2 жыл бұрын
I use this all the time. Select all ctrl+a, add cursor to every line ctrl+shift+L,end.
@bhumit070
@bhumit070 2 жыл бұрын
for me vim macros are life saver for these kind of things
@_Sizzin
@_Sizzin Жыл бұрын
I use Shift+Midde Mouse Button to select all that I want. But that's a nice way as well.
@lonlyman221
@lonlyman221 2 жыл бұрын
For inserting the commas after you have a cursor at the end of every word just “ shift-home ” : to select from the cursor to the beginning of each line line “ “ “ : Press the quote key once to make every line a string “ , “ : Press comma key once to put comma at the end of the lines … but this will also select the [ ] will it not? Will have to give that a test!! Thanks for the awesome video!!!
@dalgo_na
@dalgo_na 2 жыл бұрын
Why didn't I know of this when I needed this 😔😔
@Rizzarip
@Rizzarip Жыл бұрын
My man is higher than a rocket ship 🤣🤣🤣. His eyes are like glazed donuts
@mastershooter64
@mastershooter64 2 жыл бұрын
I just put that thing in a string and use a for loop to add commas and print it to the console and i copy paste that into an array lol
@EricLS
@EricLS 2 жыл бұрын
Ohhhhh wow. Now I know how I’m going to clean up the lists of users needing access to various things I get from user tickets in my IT job.
@nikhilhukkerikar6753
@nikhilhukkerikar6753 2 жыл бұрын
Another approach I usually use first put double quotes at the start then replace using regex match with “, all done same results
@jt099
@jt099 2 жыл бұрын
One step faster it’s just to select all the words and click your “ button, this will automatically put quotes on both sides.
@abrams11
@abrams11 2 жыл бұрын
This is so useful
@dibbyo456
@dibbyo456 2 жыл бұрын
I needed this a week ago.
@davidem3283
@davidem3283 2 жыл бұрын
I've always put the whole thing in a pair of double quotes, used .replace(), console.logged and copied the result. This may take longer, but allow you to do virtually anything with the string and you don't have to remember any shortcut, just JavaScript syntax (or whatever your favourite programming language is)
@casualoutlaw540
@casualoutlaw540 Жыл бұрын
...or you can just use the built in find and replace feature
@dbaker280
@dbaker280 2 жыл бұрын
damn i’ve been doing this with concats in excel. so inefficient!
@jot3877
@jot3877 2 жыл бұрын
I do this everytime I receive a CSV file, and need to wrap it with quotes to feed it into node.js or SQL
@liamtolkkinen5025
@liamtolkkinen5025 2 жыл бұрын
It might have just been easier to read from the file and auto generate an array using the values of the file
@BigCreep
@BigCreep Жыл бұрын
ctrl d " would have put quotes around each word selected
@caedenw
@caedenw 2 жыл бұрын
honestly though this should just be a file you load and split by new lines to build an array. a lot of times if you need a feature for something as big as this, you should be coding in a different way instead.
@mixup2216
@mixup2216 2 жыл бұрын
I didn’t know you could do this in vscode. I would have put it in notepad++ and used the advanced replace to replace
@jayztan6466
@jayztan6466 2 жыл бұрын
Hate to say this but took me a while to learn this in VS when changing from sublime
@umeshthakre416
@umeshthakre416 2 жыл бұрын
I think if you just save this using prettier extension it will add comas
@kawu42
@kawu42 2 жыл бұрын
Feel like an idiot that I've made this with regex before. Thank you for this time saving tip. :)
@stefanm578
@stefanm578 2 жыл бұрын
you also have ctrl f replace all
@happywednesday6741
@happywednesday6741 2 жыл бұрын
So you should
@brucebruce4175
@brucebruce4175 2 жыл бұрын
But this will only work with same length words. What if you have a list of words of varying lengths
@ambi488
@ambi488 2 жыл бұрын
Thankssss
20 Keyboard Shortcuts You’re A Moron for Not Using
11:08
ThioJoe
Рет қаралды 1,9 МЛН
25 VS Code Productivity Tips and Speed Hacks
11:35
Fireship
Рет қаралды 2,2 МЛН
¡Puaj! No comas piruleta sucia, usa un gadget 😱 #herramienta
00:30
JOON Spanish
Рет қаралды 22 МЛН
WHY DOES SHE HAVE A REWARD? #youtubecreatorawards
00:41
Levsob
Рет қаралды 35 МЛН
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30
How to OVER Engineer a Website // What is a Tech Stack?
11:20
Fireship
Рет қаралды 2,3 МЛН
Multiline Editing in Neovim
4:25
Andrew Courter
Рет қаралды 17 М.
My Visual Studio Code Setup for Web Development
15:22
ForrestKnight
Рет қаралды 1 МЛН
3 Bad Python Habits To Avoid
10:40
Indently
Рет қаралды 45 М.
Cursor - an AI-powered VSCode fork
12:12
Jeffrey Codes
Рет қаралды 14 М.
Code faster with these VS Code shortcuts
8:44
Coder Coder
Рет қаралды 299 М.
Don't Use a Mouse Anymore! VSCode Shortcuts Tips and Tricks
17:24
Vim Motions for absolute beginners!!!
7:25
Dispatch
Рет қаралды 126 М.
Why Does Scrum Make Programmers HATE Coding?
16:14
Thriving Technologist
Рет қаралды 487 М.
WTF Do These Even Mean
13:44
Web Dev Simplified
Рет қаралды 72 М.
😱НОУТБУК СОСЕДКИ😱
0:30
OMG DEN
Рет қаралды 2,5 МЛН
Эффект Карбонаро и бумажный телефон
1:01
История одного вокалиста
Рет қаралды 2,6 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 2,6 МЛН
👎Главный МИНУС планшета Apple🍏
0:29
Demin's Lounge
Рет қаралды 493 М.