Visual Studio Code: Multi-line and multi-cursor editing
March 25, 2018 1 Comment
CC 2.0 image courtesy Antony Theobald on Flickr
A few months back I wrote a blog post about Column Mode Editing in Notepad++. In the article, I demonstrate how to edit multiple columns of text to add, edit, or remove information. After I wrote this I wondered if we could edit multiple lines at once in Visual Studio Code. It turns out we can and there are two different ways to do it.
Multi-Line Editing
Multi-line editing is similar to column mode editing in Notepad++. The idea is to edit multiple instances of text on contiguous lines and replace it with similar information. This is useful for HTML where you may want to change several hyperlinks at once or if you want to edit multiple rows in a JSON file.
To employ multi-line editing, use the following command for your OS:
- Windows: Ctrl + Alt + Arrow Keys
- Linux: Shift + Alt + Arrow Keys
- Mac: Opt + Cmd + Arrow Keys
Multi-Cursor Editing
To edit multiple instances of text within different sections of a document, you can use multi-cursor editing. This allows multiple cursors to be placed in different spots so text can be added, modified, or deleted.
To engage multi-cursor editing, press the Alt key (or Option key on a Mac) and use the mouse to place cursors throughout the document. Every click creates a cursor resulting in multiple cursors.
Summary
This article demonstrated two ways to make multiple edits simultaneously within Visual Studio Code.
Pingback: The Morning Brew - Chris Alcock » The Morning Brew #2552