My favorite is multi-selection mode. It's not the same as "Column Mode" you find in other IDEs but try it and you will never want another editor again:
(Option)Alt-Cmd + Down or Up arrow key
From there, you can use arrow keys as normal, but instead of controlling one carrot, you control all the ones you created. So if I use the shortcut key to move to the next word, they all do, same with end of line, or what have you. In the past I had to use regex in my editors to extract quoted text in each line... now I just use multi-select. Each carrot can also be created with the mouse in the Selection menu.
Edit: Apparently it's a feature lifted from Sublime and in other IDEs - thanks!
This exists in most editors I've used (intellij is alt + shift + click or double tap alt, if I recall). I don't know how people program without this feature - they should teach this shit in school.
Multicursor is amazing.
One thing it's been great for:
I have code like:
byte b1 = array[0];
And I want to do this for 16 bytes. Control + D to duplicate 15x. Double tap control, hit up 15 times - now there's a cursor at every row. Hold control, hit right (jump by word), index to end of 'b1' on each line. Ctrl + shift + a, 'increment duplicates' - now every line is 1, 2, 3, 4... 16. `ctrl + right` my way to the index key and do the same thing.
I think loop unrolling is super cool. We're typically trained in programming to try to eliminate the kind of reuse that unrolling typically looks like, but when applied properly it can work really well. I guess that applies to most tools, though.
What actually brought it to mind was a hardware class where we were instantiating a bunch of the same module but didn't have a programmatic way to do it with our tooling. So...sorta like loop unrolling :)
All of the languages I can think of rely on the compiler backend for loop unrolling, which means it isn't a guarantee. You might want this if you need to guarantee the unroll.
But I wasn't doing this for a loop unroll.
I had a fixed size array that I wanted to serialize/ deserialize to/ from capnproto - there are no fixed size arrays in capnproto, so I wrote a message that just had b1, b2, b3... b16, and then some code to pull it out into a statically sized array. It allowed me to pull a bunch of bytes into a much larger statically allocated array without any allocation or bounds checking.
I don't know how people program without this feature
You must do some kind of programming I've not encountered in my many years. While my editor of choice can do this, I would have no idea how, because a feature like "increment duplicates" is needed so infrequently that I would never remember the shortcut.
It's one of those things that is incredibly useful. Of course it's possible to survive without it, but it's like saying "I don't know how people program without Copy and Paste". It helps.
Copy and paste is something that I use many times a day, even when I'm not programming. Needing to do the same edits over multiple lines doesn't happen often in my code.
There are appropriate plugins available for my editor, but I've never felt the need to install them.
Don't write in some insane boilerplate-driven programming language in the first place. Anyone proliferating this kind of duplication (whether with multi-cursors or shell here docs or any other way) should be flogged.
I've got to agree. It's one of those things that could save me a minute of manual editing every once in a long while, but I feel like there have to be lower-hanging fruit, in terms of increasing my editing speed.
Yea, I have the mac bindings, and for me it's opt-click to add a cursor, and ctrl-g to select next duplicate of whatever I select. You can even do stuff like "move left 1 word" or "move to begin/end of line" and all cursors follow the same behavior, possibly with different movement-distances. Utterly trivial refactorings in any language (including english), and always feels far easier to understand / predict than Vim's record-and-replay (as useful as it is), especially since you can see the results in every instance as you type.
I've been using it in editors since well before VSCode existed. It's very nearly a requirement for me to use an editor now.
I haven't tried this feature on VS Code, but isn't the record and replay macros feature in Emacs(normally bound to F3 and F4) a simpler(and more general, since seemingly it can record arbitrary text transformations) approach to achieve a similar effect?
I'm not sure where this feature originated, but it's been a core feature of Sublime for as long as I've used it, and is also broadly available in other editors. Definitely not a VS Code-specific thing, though it's still great!
I doubt it's where it originated, but I was using multi-select/multi-caret editing in jEdit before Sublime came around.
That and arbitrary window splitting (split any pane horizontally or vertically) are two features I really miss when they're not present. The latter's surprisingly hard to find; Sublime and VS Code don't do it (Atom does).
Editors like n++ have column editing, but Sublime takes it to a different level. It's most generalized, it's multi-cursor.
You can for example put your cursor on a word, spam ctrl+d (of press alt+f3) to select all instances of that word, and start editing them all at ones, no matter where they are. They don't have to be perfectly in a column. You can also copy X items from anywhere, and if you have X cursors again somewhere else and paste, they'll each go in their respective slot.
I believe it is the same functionality as in Sublime, IntelliJ, Eclipse and others. It's a total lifesaver when editing bulk stuff, like a lot of constants and what not! One of my must-haves in an IDE.
In Emacs this feature is called multiple-cursors: http://emacsrocks.com/e13.html – Emacs got it after Sublime. But I find I typically get things done faster with keyboard macros, or maybe I'm just too stuck in my ways :)
Sometimes I have 2 alternatives for a piece of code, one commented out and the other not, and I'd like to toggle between the two. With multicursor I just select both and hit `ctrl-/` to toggle them on and off.
I've had issues in IDEs where they have shitty implementations of multicursor that break that example.
I recently discovered a vscode extension literally called "Insert Cursor at Beginning of Each Line Selected".
Super handy when you want multiple cursors to line up at the start of every line (by default vscode will wrap the cursor around to the end of the longer lines if you try to move around with the arrow keys).
It saves a whole keypress (because you need to go into multicursor mode first, then press Home / Ctrl+A to get to the beginning of the line.
Additionally, there is a case where if you don't select the last line until the end, you end up in a state where the last cursor is already at the beginning. If you press "Home" now, you end up having that last cursor at the beginning of the line - and the other ones at the indentation level (see https://github.com/Microsoft/vscode/issues/14919#issuecommen...)
(Disclaimer: Author of the mentioned plugin, so I am heavily biased against my own workflow and saving-keypresses-obsession :P)
(Option)Alt-Cmd + Down or Up arrow key
From there, you can use arrow keys as normal, but instead of controlling one carrot, you control all the ones you created. So if I use the shortcut key to move to the next word, they all do, same with end of line, or what have you. In the past I had to use regex in my editors to extract quoted text in each line... now I just use multi-select. Each carrot can also be created with the mouse in the Selection menu.
Edit: Apparently it's a feature lifted from Sublime and in other IDEs - thanks!