Pull to refresh
Microsoft — мировой лидер в области ПО и ИТ-услуг

Visual Studio for Mac: Top Features of the New Editor

Reading time4 min
Over the past year, the Visual Studio for Mac team updated the editors within the IDE to be faster, more fluent and more productive. We did this by building a macOS-native editor interface on top of the same editor backend as Visual Studio on Windows. In version 8.1 we introduced the new C# editor. This was followed by the new XAML editor in 8.2. And most recently, we updated our web languages to utilize the new editors in version 8.3, completing the process we set out to do a year ago. To celebrate this accomplishment, I wanted to share a bit of detail regarding the design and implementation of the new editors along with my five favorite new features in the Visual Studio for Mac code editors.

At the core of the updated editors within Visual Studio for Mac is the shared language service with Visual Studio on Windows. What this means is that the same backend that powers the Windows version of Visual Studio now powers the macOS version as well. This includes IntelliSense, Roslyn, text logic, and all the language services behind the scenes. The only portion not shared between Windows and macOS is the UI layer, which stays native for each platform. In the case of macOS, that means using macOS frameworks like Cocoa and CoreText to power the UI experience. By using a native UI, while also being able to utilize support for native input methods as well as support for right-to-left languages, font ligatures and other advanced graphical features.

This article in our blog.

Now that we have the power of the new editor in the IDE, let’s take a look at my top 5 favorite new editor features. All of the features I want to share with you today are aimed at making your development experience more productive, delightful and fun. I hope you enjoy using them as much as we enjoyed developing them!

Multi-Caret Editing

Multi-caret allows you to insert any number of carets (text insertion points) within the file you are editing. This can be accomplished manually through mouse clicks with control-option-click or through the keyboard. When using the keyboard, you can utilize pattern matching to insert next matching (Option+Shift+.) or insert all matching (Option+Shift+;). You can also remove the last inserted caret with Option+Shift+, or move the last caret down with Option+Shift+/. In the below GIF, I use the Option+Shift+. hotkey to insert the next matching caret twice, allowing me to edit all three instances of «double» within this page.

Multi-caret editing is a very powerful feature that can greatly reduce the time associated with editing multiple lines at the same time. For example, if you need to change a prefix on several variables, or switching specific var declarations to strongly typed declarations, multi-caret editing allows you to do this with ease.


IntelliSense Type Filtering

The next feature that I want to highlight is IntelliSense Type Filtering. With IntelliSense Type Filtering, you can filter the completion list by type of completion. If, for example, you only want to see classes in your completion list, you can either click the classes icon or use the hotkey «option-c». We have a full list of types that you can filter by, in addition to their corresponding icons and hotkeys in our Visual Studio for Mac Documentation. In the GIF below, I use IntelliSense type filtering to focus my list on interfaces, structures and finally on delegates.

This feature really comes in handy when you can’t recall the exact name of the item you want, or simply want to focus solely on a specific type. It also works super well when combined with my next favorite feature, Show Import Items.

Show Import Items

Often, when I am working on a project, I can’t always recall the exact namespace I need to import into my code file for a specific type. This often leads me to panic and feverishly search anywhere I can to find the import I need. This next feature alleviates this angst by not only showing completions which I have already imported, but also completions that are available for import. Additionally, if I end up selecting one of the not-yet-imported completions, the using statement will be added to the header of the code file. In the below GIF, I add «System.ComponentModel.DataAnnotations» to my project through the Show Import Items feature. You may have also noticed that for items which are not yet imported, the full namespace is listed next to the type, making it easy to see what the system is going to add to your header.

Show Import Items is currently disabled by default, but you can easily enable it by opening Visual Studio > Preferences > Text Editor > IntelliSense and enabling «Show Import Items».

Right-to-Left and Native Input Support

A top ask from our community was to enable support of right-to-left and bi-directional languages, and we incredibly excited to offer support for those requests in Visual Studio 2019 for Mac. In the old editors, typing or pasting right-to-left strings, such as those in Persian, Hebrew or Arabic, would result in the word appearing to be in reverse. For example, the word for «hello» would appear to say «olleh», flipping the text around so that it appears reversed. With the new editors, right-to-left and all types of bi-directional text are supported.

We’ve also introduced native input support. As the editors are built using the native toolkit for macOS, inserting text into the editor is just like inserting in any other native macOS app. This means that you get access to all of the advanced text entry features of macOS, such as long-press for accented and alternate characters as well as the emoji selector!

Ligature Support

If you use a font which supports ligatures, such as the newly released Cascadia Code, Visual Studio for Mac 2019 will automatically support the insertion of ligatures in place of common dual character glyphs. For example, the double-equal sign (==) will be transformed into an elongated equal sign with no space. Likewise, the bang-equals (!=) will be transformed to an equal sign with a slash throughout, more accurately depicting the «does not equal» symbol which bang-equals is intended to represent.
In the below GIF, I use a simple «if» statement to demonstrate the available ligatures for several different common multi-character glyphs.

Download Visual Studio 2019 for Mac

These are my five favorite editors features in Visual Studio for Mac 2019, but there are plenty more to experience as you work through a project. To get started with Visual Studio 2019 for Mac Download the Visual Studio 2019 for Mac v8.3 release today, or if you have it installed already – update to the latest release using the Stable channel!

If you run into any issues with the v8.3 release, please use the Help > Report a Problem menu in the IDE to let us know about it. You can also provide suggestions for future improvements by using the Provide a Suggestion menu.

Finally, make sure to follow us on Twitter at @VisualStudioMac to stay up to date on the latest Visual Studio for Mac news and let us know what your experience has been like. We look forward to hearing from you!
Total votes 3: ↑3 and ↓0+3