<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>VSCode Hints and Tips on Much Ado About IT</title><link>https://it.knightnet.org.uk/kb/vscode/</link><description>
Recent content about VSCode Hints and Tips from Much Ado About IT |
Ramblings and rantings from IT Architect &amp; Designer, Julian Knight</description><generator>Hugo | gohugo.io | Theme twenty-sixteen</generator><language>en-gb</language><copyright>This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</copyright><lastBuildDate>Mon, 24 Apr 2023 21:27:28 +0000</lastBuildDate><atom:link href="https://it.knightnet.org.uk/kb/vscode/feed.xml" rel="self" type="application/rss+xml"/><item><title>VSCode - multiple cursors</title><link>https://it.knightnet.org.uk/kb/vscode/select-same-text/</link><guid isPermaLink="true">https://it.knightnet.org.uk/kb/vscode/select-same-text/</guid><pubDate>Wed, 10 Jan 2018 22:00:00 +0000</pubDate><guid>https://it.knightnet.org.uk/kb/vscode/select-same-text/</guid><description><div>VSCode supports multi-cursor editing, here are some tips on using it.</div><div>&lt;p>Note that, in multi-cursor mode, the standard selection shortcuts also work.&lt;/p>
&lt;h3 id="change-all-the-same-text-in-a-document-to-something-else">Change all the same text in a document to something else&lt;/h3>
&lt;p>If you want to quickly change all of the same text in a document:&lt;/p>
&lt;ul>
&lt;li>Select the text or code that you want to change. VSCode highlights all matching text.&lt;/li>
&lt;li>Press &lt;!-- raw HTML omitted -->Ctrl+F2&lt;!-- raw HTML omitted --> and type your new text.&lt;/li>
&lt;/ul>
&lt;p>VSCode supports multi-cursor editing which this tip makes use of.&lt;/p>
&lt;h3 id="multi-cursor-mouse-shortcuts">Multi-cursor mouse shortcuts&lt;/h3>
&lt;ul>
&lt;li>&lt;!-- raw HTML omitted -->Alt&lt;!-- raw HTML omitted --> and click will add additional cursors. (Note that some Linux distributions may map a system function to &lt;!-- raw HTML omitted -->Alt+LeftMouse&lt;!-- raw HTML omitted --> which may interfere with this shortcut).&lt;/li>
&lt;li>&lt;!-- raw HTML omitted -->Shift+Alt&lt;!-- raw HTML omitted --> and drag does a box select with cursors on every line selected.&lt;/li>
&lt;/ul>
&lt;h3 id="multi-cursor-keyboard-shortcuts">Multi-cursor keyboard shortcuts&lt;/h3>
&lt;ul>
&lt;li>
&lt;p>&lt;!-- raw HTML omitted -->Ctrl+Alt+Up&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Alt+Down&lt;!-- raw HTML omitted --> extends multiple cursors upwards and downwards from the previously selected cursors. Note that using both up and down after each other extends around the previous cursors.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;!-- raw HTML omitted -->Ctrl+D&lt;!-- raw HTML omitted --> selects next occurrence of word under cursor or of the current selection&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;!-- raw HTML omitted -->Ctrl+K&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+D&lt;!-- raw HTML omitted --> moves last added cursor to next occurrence of word under cursor or of the current selection
The commands use matchCase by default. If the find widget is open, then the find widget settings (matchCase / matchWholeWord) will be used for determining the next occurrence&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;!-- raw HTML omitted -->Ctrl+U&lt;!-- raw HTML omitted --> undoes the last cursor action, so if you added a cursor too many or made a mistake, you can press &lt;!-- raw HTML omitted -->Ctrl+U&lt;!-- raw HTML omitted --> to go back to the previous cursor state. Adding cursor up or down (&lt;!-- raw HTML omitted -->Ctrl+Alt+Up&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Alt+Down&lt;!-- raw HTML omitted -->) now reveals the last added cursor to make it easier to work with multiple cursors on more than 1 viewport height at a time (i.e. select 300 lines and only 80 fit in the viewport).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;!-- raw HTML omitted -->Ctrl+Shift+Alt+Up&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Shift+Alt+Down&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Shift+Alt+Left&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Shift+Alt+Right&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Shift+Alt+PageUp&lt;!-- raw HTML omitted -->, &lt;!-- raw HTML omitted -->Ctrl+Shift+Alt+PageDown&lt;!-- raw HTML omitted --> extend selections of box-selections. If standard multi-cursors selected, will box-select around the first cursor.&lt;/p>
&lt;p>These shortcuts are not available on Linux&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>Some options don&amp;rsquo;t appear to work on my Windows 10 installation - possibly due to clashing shortcuts from extensions:&lt;/p>
&lt;ul>
&lt;li>&lt;!-- raw HTML omitted -->Alt+Shift+L&lt;!-- raw HTML omitted --> Selects all the same words that the first cursor is in. (Similar to selecting text and then &lt;!-- raw HTML omitted -->Ctrl+F2&lt;!-- raw HTML omitted -->). This works from the menu but not from the keyboard shortcut.&lt;/li>
&lt;li>&lt;!-- raw HTML omitted -->Alt+Shift+I&lt;!-- raw HTML omitted --> extend cursor selections to end of line.&lt;/li>
&lt;/ul>
&lt;h3 id="changing-the-keyboard-modifier">Changing the keyboard modifier&lt;/h3>
&lt;p>The &lt;code>editor.multiCursorModifier&lt;/code> can be set to either:&lt;/p>
&lt;ul>
&lt;li>&lt;code>ctrlCmd&lt;/code> - Maps to &lt;!-- raw HTML omitted -->Ctrl&lt;!-- raw HTML omitted --> on Windows and &lt;!-- raw HTML omitted -->Cmd&lt;!-- raw HTML omitted --> on macOS.&lt;/li>
&lt;li>&lt;code>alt&lt;/code> - The default &lt;!-- raw HTML omitted -->Alt&lt;!-- raw HTML omitted -->.&lt;/li>
&lt;/ul>
&lt;p>This can also be toggled from the &lt;code>Selection&lt;/code> menu.&lt;/p>
&lt;h3 id="multi-cursor-menu-items">Multi-cursor menu items&lt;/h3>
&lt;p>The &lt;code>Selection&lt;/code> menu has a number of entries related to multiple cursors.&lt;/p></div></description><author>Julian Knight</author><category domain="https://it.knightnet.org.uk/categories/development">Development</category><category domain="https://it.knightnet.org.uk/tags/vscode">vscode</category></item></channel></rss>