Visual Studio editing tricks
Posted: January 7th, 2020, 4:53 am
Figured I just keep a running list here to make things easier than just looking through the entire thread if it goes multiple pages:
Text editing keyboard shortcuts
Home: Move cursor to beginning of line of text, press again to go to far left of window
End: Move cursor to end of text and white space, tabs or spaces
Ctrl + C ( With something highlighted ): Copies highlighted text to clipboard
Ctrl + C ( With nothing highlighted ): Copy current line to clipboard
Ctrl + X ( With something highlighted ): Cuts highlighted text
Ctro + X ( With nothing highlighted ): Cuts current line
Ctrl + V ( With something highlighted ): Paste copied text from clipboard
Shift + Delete ( with something highlighted ): Cut highlighted text
Shift + Delete ( with nothing highlighted ): Cut entire line of text
Shift + Insert: Paste any copied text from clipboard
Alt + Shift + Up/Down: Multiple cursors for multi-line edits
Alt + Shift + Arrows: Allows you to select regions instead of entire lines
Alt + Left Click: Same as above for KB and Mouse interaction
Alt + Up/Down: Swap line of text with line above or below the line the cursor is on
Ctrl + Backspace/Delete: - Deletes word to the right of cursor to the next punctuation or beginning of next word
Ctrl + Up/Down: Scrolls the window up or down without moving the cursor
Navigation shortcuts
Ctrl + T: Opens a search box to find something in your project
Ctrl + Tab: Brings up a list of open documents, keep pressing tab while holding Ctrl to select a different document, release Ctrl to go to that document
F1: Opens a browser window to msdn. If you have something Win32 or C++ related ( c++ keywords or Win32 api functions or types ), "helpful" information will show up like a help document for what 'const' is or how to use IDXGISwapChain.
Debug keyboard shortcuts
F5: Runs the project in it's current mode ( Debug or Release ).
Shift + F5: Runs the project without being attached to VS ( no performance utilities running )
F9: Set break point on same line as cursor
F10: Steps over next line skipping function calls
F11: Step into next line, steps into functions or just steps over normal code
Outlining keyboard shortcuts
Ctrl+M,O: Starts/Enables outlining which collapses functions down to their declarations
Ctrl+M,P: Stops/Disables outlining which expands functions
Ctrl+M,L: If outlining is enabled, toggles outlining of all scopes
As text editors go, Visual Studio isn't the most flexible and is probably why most use VIM or something similar. However, there are a few nice features I'd like to share that I use regularly.
Multi-line edits: Hold down ALT and press the UP or DOWN arrows. This will give you multiple cursors.
Box highlighting: Hold down ALT and SHIFT while moving the cursor around. This allows you to cut/copy aligned blocks of code.
Multi-line paste duplicates: Copy a section of code like normal, then use ALT plus SHIFT plus the UP or DOWN arrow keys for however many copies you want, then press CTRL+V to paste. This will paste whatever text was in the clipboard on each line you have selected for multi-line edit.
Move lines of code, without copy/paste: Place the cursor on any line in the editor window, hold down the ALT while pressing the UP or DOWN arrows. If you press UP then the current line moves up one line or swaps with the line above. If you press DOWN then the current line is swapped with the line below. This is great for quickly reordering the lines of code without having to cut and paste.
Text editing keyboard shortcuts
Home: Move cursor to beginning of line of text, press again to go to far left of window
End: Move cursor to end of text and white space, tabs or spaces
Ctrl + C ( With something highlighted ): Copies highlighted text to clipboard
Ctrl + C ( With nothing highlighted ): Copy current line to clipboard
Ctrl + X ( With something highlighted ): Cuts highlighted text
Ctro + X ( With nothing highlighted ): Cuts current line
Ctrl + V ( With something highlighted ): Paste copied text from clipboard
Shift + Delete ( with something highlighted ): Cut highlighted text
Shift + Delete ( with nothing highlighted ): Cut entire line of text
Shift + Insert: Paste any copied text from clipboard
Alt + Shift + Up/Down: Multiple cursors for multi-line edits
Alt + Shift + Arrows: Allows you to select regions instead of entire lines
Alt + Left Click: Same as above for KB and Mouse interaction
Alt + Up/Down: Swap line of text with line above or below the line the cursor is on
Ctrl + Backspace/Delete: - Deletes word to the right of cursor to the next punctuation or beginning of next word
Ctrl + Up/Down: Scrolls the window up or down without moving the cursor
Navigation shortcuts
Ctrl + T: Opens a search box to find something in your project
Ctrl + Tab: Brings up a list of open documents, keep pressing tab while holding Ctrl to select a different document, release Ctrl to go to that document
F1: Opens a browser window to msdn. If you have something Win32 or C++ related ( c++ keywords or Win32 api functions or types ), "helpful" information will show up like a help document for what 'const' is or how to use IDXGISwapChain.
Debug keyboard shortcuts
F5: Runs the project in it's current mode ( Debug or Release ).
Shift + F5: Runs the project without being attached to VS ( no performance utilities running )
F9: Set break point on same line as cursor
F10: Steps over next line skipping function calls
F11: Step into next line, steps into functions or just steps over normal code
Outlining keyboard shortcuts
Ctrl+M,O: Starts/Enables outlining which collapses functions down to their declarations
Ctrl+M,P: Stops/Disables outlining which expands functions
Ctrl+M,L: If outlining is enabled, toggles outlining of all scopes
As text editors go, Visual Studio isn't the most flexible and is probably why most use VIM or something similar. However, there are a few nice features I'd like to share that I use regularly.
Multi-line edits: Hold down ALT and press the UP or DOWN arrows. This will give you multiple cursors.
Box highlighting: Hold down ALT and SHIFT while moving the cursor around. This allows you to cut/copy aligned blocks of code.
Multi-line paste duplicates: Copy a section of code like normal, then use ALT plus SHIFT plus the UP or DOWN arrow keys for however many copies you want, then press CTRL+V to paste. This will paste whatever text was in the clipboard on each line you have selected for multi-line edit.
Move lines of code, without copy/paste: Place the cursor on any line in the editor window, hold down the ALT while pressing the UP or DOWN arrows. If you press UP then the current line moves up one line or swaps with the line above. If you press DOWN then the current line is swapped with the line below. This is great for quickly reordering the lines of code without having to cut and paste.