Tip: Hotkey for quickly moving lines of code in VS and VS Code

Posted by

While I’m programming, I often use different code editors for different use cases, and one of my absolute favorite distinct hotkey controls is within Visual Studio and Visual Studio Code. You can very quickly move lines of code up and down using the “Alt-Arrow [Up/Down]”.

As seen below in the gif, after typing out some code, pressing Alt-Arrow Down moved the line of code where my cursor was down, and the line below it up.

Additionally, if you highlight multiple lines and use an Alt-Arrow command, you can shift multiple lines at a time:

Getting used to this hotkey can be kind of weird, but it can help speed up your coding and make things a bit easier. More Visual Studio hotkeys can be found here: https://docs.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-in-visual-studio

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.