JetBrains MPS Shortcuts

MPS Shortcuts mug

If you would like to order one mug with the most useful MPS Shortcuts printed on it, like the one in the image, Send an e-mail to us with the button below.

500

Introduction

JetBrains MPS is a large and complex system that has been developed for approximately 15 years. It has a lot of windows, toolboxes, settings and tabs. A skilled user can work with it almost entirely with a keyboard in a very fast manner by using keybinds. Learning all of these shortcuts and trying to use them looks daunting to newcomers and that’s why we decided to write a post where we will go through the most useful shortcuts and explain how they are used and in what context.

Node Structure

Before we start it’s very important to understand nodes and their structure. Almost everything in MPS is a node. Therefore it is vital to learn how nodes work so we understand what is happening in the editor and why sometimes the application works in ways that we are not expecting it to. For further explanation refer to our getting started with MPS post.

Node hierarchy works in a tree structure.
tree structure
Figure 1. Tree structure

Model, Module and Root Node

The following three things define the Project structure, presented in the logical view.

Root nodes are the top-most elements of a model. They are things like classes, enums, concepts and concept editors, but they can also be custom root nodes that are from concepts of our creation, like the "The Bookshelf" Library one in the following image.

mps root nodes
Figure 2. Examples of root nodes

Models are what organizes the root nodes. They hold meta information about what models they use, languages that they are written in, information about the model file and special generator parameters. For example - the structure aspect is a model of the Library language Module. In it we group all root nodes relating to the language structure.

mps models
Figure 3. Examples of models

Modules organize models into higher level entities. There are four types of modules in MPS: solutions, languages, devkits and generators.

mps modules
Figure 4. Examples of modules
For more information on the project structure see the MPS documentation.

Editing

Move Node up | Move Node down

Move node up

Move node down

win logo

Ctrl+Shift+

Ctrl+Shift+

apple logo

+Shift+

+Shift+

This shortcut is used to move selected nodes backwards and forwards in a list in their respected level (see Tree structure).

If we select parent 2 and move it with this shortcut we will move it in the Level 2 layer not up or down to Level 1 or Level 3.

Nodes do not need to be selected. The cursor pointing to the node in question is also enough to move chosen node.
Before

225

After

225

This works for any node — it works in BaseLanguage and in language editing tabs like concepts, editors, generators etc.

(Un)Comment Line

win logo

Ctrl+/

apple logo

+/

This action helps with faster commenting of multiple selected lines. If we want to comment out just one line we could also write "//" at the beginning of the line but the shortcut is better because the cursor doesn’t need to be at a specific place. If the line is already commented out we can use the shortcut again to uncomment it.

Duplicate Selection

win logo

Ctrl+D

apple logo

+D

This action duplicates selected nodes or the node at the current cursor.

Selection

Move to Previous Entry | Move to Next Entry

Previous entry

Next entry

win logo

Shift+ (Tab key)

(Tab key)

apple logo

+ (Tab key)

(Tab key)

These actions help us with navigation inside the main editor. With them we move the cursor to next or previous node that can be edited.

Select Sibling | Deselect Sibling

Select sibling

Deselect sibling

win logo

Shift+

Shift+

apple logo

+

+

With these actions we can (De)Select Siblings of the current selected node or cursor location. They select nodes sideways in the Tree structure.

Select Parent | Deselect Parent

Select parent

Deselect parent

win logo

Ctrl+

Ctrl+

apple logo

+

+

With these actions we can (de)select parents of the current selected node or cursor location. They select nodes up or down in the Tree structure.

These actions help us with project navigation (more information can be found in the docs).

Go to Definition

win logo

Ctrl+B or Ctrl+left-Click

apple logo

+B or +left-Click

With them we can go to node and code definitions. They are very useful when we need to check out definitions from our project and the modules pool.

Navigate back

Navigate forward

win logo

Ctrl+Alt+

Ctrl+Alt+

apple logo

++

++

These actions move through the history of the current open tab in the main editor. It works like a browsers back and forward buttons.

navigate history
Figure 5. History navigation buttons

This toolbar can be opened from the menu at View  Appearance  Toolbar.

Editor

Focus Editor

win logo
apple logo

Esc

This action brings back the focus to the main editor if we have clicked somewhere else or used another MPS window or menu.

Close Current Editor

win logo

Ctrl+F4

apple logo

+W

Closes the currently focused window in MPS e.g. a tab in the main editor, the logical view or the inspector.

Switch to Previous Editor | Switch to Next Editor

Switch previous editor

Switch next editor

win logo

Ctrl+Shift+ (Tab key)

Ctrl+ (Tab key)

apple logo

++ (Tab key)

+ (Tab key)

This opens the Switcher window that cycles through various windows and open main editor tabs. (JetBrains Switcher)

Switch to Previous Tab | Switch to Next Tab

Switch previous tab

Switch next tab

win logo

Alt+Shift+

Alt+Shift+

apple logo

++

++

This switches the tabs in multi-editor tabs like the Language structure editors.

multi editor tab
Figure 6. Language Structure Behaviour Tab
multi editor tab 1
Figure 7. Language Structure Typesystem Tab

Switch to Left Editor | Switch to Right Editor

Switch left editor

Switch right editor

win logo

Alt+

Alt+

apple logo

+

+

This switches to the left or right open editors in the main window. With them we navigate the tabs inside the orange rectangle.

switch to left
Figure 8. From AItem
switch to left 2
Figure 9. Switch to LibraryContainer

Show Recent Editors Pop-up

win logo

Ctrl+E

apple logo

+E

Opens the Recent Files window that has links to useful windows and recently used files.

recent files window
Figure 10. Recent Files Window
For more information about editor navigation see the MPS documentation.

Find

Find Text in Editor

win logo

Ctrl+F

apple logo

+F

Opens the find menu that allows us to search for strings in the current editor.

find
Figure 11. Find menu

Find Previous Text | Find Next Text

Find previous text

Find next text

win logo
apple logo

Shift+F3

F3

When the main editor is focused and a find dialog is set up to search for a string, these shortcuts move the cursor to the previous or next occurences relative to the cursor position.

Find Usages

win logo

Alt+F7

apple logo

+F7

Finds project-wide usages of the currently selected node.

find usages window
Figure 12. Usages window

Find Usages with Options

win logo

Ctrl+Alt+Shift+F7

apple logo

+++F7

Opens the find usages popup window that has options for searching usages of the currently selected node.

find usages
Figure 13. Find usages popup window

Find Concept Instances

win logo

Alt+F6

apple logo

+F6

Finds all instances of currently selected concept. This works with concept and class declarations in most language editors.

Go to Previous Find Result | Go to Next Find Result

Go to previous find result

Go to next find result

win logo

Ctrl+Alt+

Ctrl+Alt+

apple logo

++

++

When a find usages or find instances task is open and executed we can move through the search results with these shortcuts.

usages next previous
Figure 14. Usages window
For more information on finders see MPS documentation.

Go to Model by Name

win logo

Ctrl+Alt+Shift+M

apple logo

++O

Opens a small window that asks for a model name and displays search results in a drop-down list. User can navigate with / and Enter to select destination.

model by name
Figure 15. Go to model by name window

Go to Module by Name

win logo

Ctrl+Alt+Shift+S

apple logo

++O

Opens a small window that asks for a module name and displays search results in a drop-down list. User can navigate with / and Enter to select destination.

module by name
Figure 16. Go to module by name window

Go to Root Node by Name

win logo

Ctrl+N

apple logo

+O

Opens a small window that asks for a root node name and displays search results in a drop-down list. User can navigate with / and Enter to select destination.

root node by name
Figure 17. Go to rood node by name window

Error

Refresh Error Messages

win logo
apple logo

F5

Refreshes error at current cursor location. This is useful when you’ve fixed an error but it still shows up in the editor.

Show Selected Error Message

win logo

Ctrl+F1

apple logo

+F1

Shows the error message in a popup bubble at the currently selected node, if there is an error.

Go to Previous Error | Go to Next Error

Go to previous error

Go to next error

win logo
apple logo

Shift+F2

F2

Jump to next/previous error relative to the current cursor location inside the main editor.

Go to Error Rule

win logo

Ctrl+Alt+R

apple logo

++R

Go to the definition of the error that is at the current cursor location. This can be a constraint or typesystem root node. It’s usefulness is in tracking constraints in our project and/or rules that are defined by the Modules pool node, that we use in our DSLs.

modules pool
Figure 18. Project node and Modules pool node

Entry

Auto-Complete

win logo

Ctrl+Space

apple logo

+Space

This is one of the most used shortcuts. It’s going to be used everywhere we write code. It opens the Auto-complete popup and gives context specific suggestions. Use / and Enter to select entry for the current cursor location.

auto complete menu
Figure 19. Auto complete menu

Auto-Complete Reset

win logo

Ctrl+Space

apple logo

+Space

Use this to restart the auto-complete function so we start writing from the beginning of the node.

auto complete menu
Figure 20. Auto complete menu
auto complete reset menu
Figure 21. Auto complete reset menu

Show Intentions

win logo

Alt+Space

apple logo

+Space

This is also one shortcut that is used a lot. It opens the Intentions popup that has context specific actions we can take with the current node.

Import

Import Language

win logo

Ctrl+L

apple logo

+L

Opens a popup window that allows us to search for languages that we can add to the current model’s Used Languages inside the Model properties. Use / and Enter to select the language dependency.

import language
Figure 22. Import language

Import Model

win logo

Ctrl+M

apple logo

+M

Opens a popup window that allows us to search for models that we can add to the current model’s Dependencies list. Use / and Enter to select the model dependency.

import model
Figure 23. Import model

Import Model by Root Name

win logo

Ctrl+R

apple logo

+R

Opens a popup window that allows us to search for root nodes and add the model that contains it to the current model’s Dependencies list. Use / and Enter to select the model dependency.

import model by rootname
Figure 24. Import model by root name

Language

Show Type

win logo

Ctrl+Shift+P

apple logo

++P

This works on every node with a defined typesystem. Opens the Type Explorer window that shows the type of the currently selected node.

type explorer window
Figure 25. Type explorer

Show Parameters

win logo

Ctrl+P

apple logo

+P

Opens a buble popup that shows possible method parameters that can be input in the method call at the current node. The cursor has to point to a method call for this to work.

show parameters
Figure 26. Method parameters

Open Concept

win logo

Ctrl+Shift+S

apple logo

++S

Opens the concept declaration of the current node. This is useful to track down concepts from our project and the modules pool.

Open Editor

win logo

Alt+Shift+E

apple logo

++E

Opens the editor declaration of the currently selected node. This is useful to track down editor declarations from our project and the modules pool.

Show Inheritance Hierarchy

win logo

Ctrl+H

apple logo

+H

This works for BaseLanguage editors and concept node editors. Opens the Hierarchy window that allows us to track the inheritance of the currently selected node. This is useful to inspect inheritance from our project and the modules pool.

hierarchy window
Figure 27. Inheritance window

IDE

Show Structure

win logo

Ctrl+F10

apple logo

+F10

Opens a pop-up window that shows the root nodes in relation to the currently selected root node. Works with Language root nodes.

Show Outline

win logo

Ctrl+F12

apple logo

+F12

Similar to the show structure shortcut but works with most nodes. It’s created from the root node’s descendants.

Open/Focus Inspector

win logo

Alt+2

apple logo

+2

Opens the Inspector window or focuses on it if it’s already opened.

Select Root in Project Pane

win logo

Alt+F1, Enter

apple logo

+F1, Enter

Alt+F1 opens the Select in popup window that allows us to see the path of current node in various IDE locations. Enter is to select the entry. This is useful to track down nodes from our project and the modules pool.

select in popup
Figure 28. Select popup window

Select Node in Project Pane

win logo

Alt+F2

apple logo

+F2

Works similarly to the Select root in project pane but skips opening the Select in popup window and directly points at the location of the node in the logical view. The main difference is it jumps to the selected nodes, if we have activated the Show Members option in the Logical view. This is useful to track down nodes from our project and the modules pool.

show members cog
Figure 29. Show members cog menu
select node project pane
Figure 30. Select node in project pane

Execute Action by Name

win logo

Ctrl+Shift+A

apple logo

++A

This is an exceptionally useful shortcut. It opens the Actions window that can show us context sensitive actions we can take. It allows us to search for actions by name or by keybinding. We can also remove the context sensitivity so we can search all MPS actions.

execute action
Figure 31. Execute action menu

Build

Make Current Module

win logo

Ctrl+F9

apple logo

+F9

A very useful shortcut. This calls the make action. We will use this action very often because most of the time when we edit models we have to build them to see the difference they make in other models that are using them.

Rebuild Current Model

win logo

Ctrl+Shift+F9

apple logo

++F9

A very useful shortcut. This calls the rebuild action.

The difference between this shortcut and the previous one is that the make action builds only the selected models changed items, while the rebuild action recompiles everything, regarding the target, from scratch. Inside the Logical View next to the names of items we see (generation required).

rebuild make
Figure 32. Generation required

If we were to run the make action inside the Library language only the structure and editor aspects would be recompiled. If we were to run the rebuild action everything inside the Library language would be recompiled.

Both make and rebuild actions are available on the model and module levels.
Use the rebuild action in case make doesn’t build properly or something breaks after it.

Refactor

Surround-With Intentions

win logo

Ctrl+Alt+T

apple logo

++T

This action works with BaseLanguage in specific circumstances. It opens the Surround with popup window. It allows us to define logic or loops fast. We can call this action when the cursor has selected some code, at the end and the beginning of a node.

surround with menu
Figure 33. Surround with intentions menu

Move Node

win logo
apple logo

F6

Opens the Move nodes window in which we can select a model that the currently opened node will be moved to.

move node menu
Figure 34. Move node menu

Rename Node

win logo
apple logo

Shift+F6

Opens the Rename node dialog in which we can specify a new name for our node.

rename node popup
Figure 35. Rename node menu

Extract Variable

win logo

Ctrl+Alt+V

apple logo

++V

Works in BaseLanguage and is used for expressions. Moves the currently selected node to a variable definition.

Inline Variable

win logo

Ctrl+Alt+N

apple logo

++N

Works in BaseLanguage. Does the opposite of the extract variable shortcut — Moves the currently selected node to an inline variable where it is being used.

Extract Method

win logo

Ctrl+Alt+M

apple logo

++M

Opens the Extract Method window that allows us to extract the selected nodes into a separate method inside the root node.

extract method menu
Figure 36. Extract method menu

Implement Methods

win logo

Ctrl+I

apple logo

+I

Opens the Select methods to Implement window. In it, we can choose methods that we can implement in the root node. It’s useful to quickly get a method header. Works when our node is implementing an interface or inheriting methods that must be implemented.

implement methods
Figure 37. Implement methods menu

Override Methods

win logo

Ctrl+O

apple logo

+O

Opens the Select methods to Override/Implement window. In it, we can choose methods that we can override in the root node. It’s useful to quickly get a method header so we can override it. Works when our node is implementing an interface or inheriting methods that can be overridden.

override methods
Figure 38. Override methods menu