Commanding the editor
When you are coding in MPS you will notice there are some differences between how you normally type code in text editors and how code is edited in MPS. In MPS you manipulate the AST directly as you type your code through the projectional editor. The editor gives you an illusion of editing text, which, however, has its limits. So you are slightly limited in where you can place your cursor and what you can type on that position. As we believe, projectional editor brings huge benefits in many areas. It requires some getting used to, but once you learn a few tricks you'll leave your plain-text-editor colleagues far behind in productivity and code quality. In general, only the items suggested by a completion menu can be entered. MPS can always decide, which elements are allowed and which are disallowed at a certain position. Once the code you type is in the red color you know you're off the track.
Code completion
Code completion Ctrl+Space will be your good friend allowing you to quickly complete the statements you typed. This is the default way to enter new things.
It is positioned with the current text cell and can be filtered further by typing ahead. Remember that CamelHumps are supported, so you only need to type the capital characters of long names and MPS will guess the rest for you.
The completion menu contains from 1 up to hundreds of items, sorted by groups. Defining hierarchical menus for it will be flattened so the leaves of them will be listed as well as menu titles.
Open it with Ctrl+Space. Type to filter. Select an item with arrow keys, or clicking it. Finish with Tab, Enter, or double-click. Abort with Escape, clicking outside the menu, or changing to another application (for example Alt ). To reduce the filtering, press left arrow; to jump to the beginning to remove all filtering press Ctrl+Space for a second time.
Intentions
Frequently you can enhance or alter your code by means of predefined semi-automated procedures called Intentions. By pressing Alt+Enter MPS will show you a popup dialog with options applicable to your code at the current position. Some intentions are only applicable to a selected code region, for example, to wrap code inside a try-catch block. These are called Surround With intentions and once you select the desired block of code, press Ctrl+Alt+T to show the list of applicable intentions.
Navigation
Whenever you need to see the definition of an element you are looking at, press Ctrl+B or Ctrl + mouse click to open up the element definition in the editor. To quickly navigate around editable positions on the screen use Shift+Tab. Enter will typically insert a new element right after your current position and let you immediately edit it. The Insert key will do the same for a position right before your current position.
When a piece of code is underlined in either red or yellow, indicating an error or a warning respectively, you can display a popup with the error message by hovering your mouse over the error or by pressing Ctrl+F1.
Selection
Ctrl+Up / Ctrl+Down key combination allows you to increase/decrease block selection. It ensures you always select valid subtrees of the AST. The usual Shift + Arrow keys way of text-like selection is also possible.
Investigation
To quickly find out the type of an element, press N/A will open the selected element in the Node Explorer allowing you to investigate the appropriate part of the AST. Alt+F7 will enable you to search for usages of a selected element. To quickly visualize the inheritance hierarchy of an element, use Ctrl+H.
Inspector window
The Inspector window opens after you press Alt+2. Some code and properties (for example editor styles, macros and so on) are shown and edited inside the Inspector window so it is advisable to keep the window ready.
Most useful key shortcuts
Shortcut | Action |
---|---|
Ctrl+Space | Code completion |
Ctrl+B | Go To Definition |
Alt+Enter | Intentions |
Tab | Move to the next cell |
Shift+Tab | Move to the previous cell |
Ctrl+Up Ctrl+Down | Expand/Shrink the code selection |
Shift + Arrow keys | Select regions |
Ctrl+F9 | Compile project |
Shift+F10 | Run the current configuration |
N/A | Show the type of the expression under caret |
N/A | Open the expression under caret at the Node Explorer to inspect the appropriate node and its AST surroundings |
Ctrl+H | Show the structure (inheritance hierarchy) |
Alt+Insert | A generic contextual New command - will typically popup a menu with elements that can be created at the given location |
Ctrl+Alt+T | Surround with... |
Ctrl+O | Override methods |
Ctrl+I | Implement methods |
Ctrl+/ | Comment/uncomment the current node |
Ctrl+Shift+/ | Comment/uncomment with block comment (available in BaseLanguage only) |
Ctrl+X | Cut current line or selected block to buffer |
Ctrl+C | Copy current line or selected block to buffer |
Ctrl+Shift+Alt+V | Paste from buffer |
Ctrl+Shift+V | Paste from history (displays a popup dialog that lists all previously copied code blocks) |
Ctrl+Z | Undo |
N/A | Re-do |
Ctrl+D | Duplicate current line or selected block |
Complete listing
Refer to the Default Keymap Reference page for a complete listing of MPS keyboard shortcuts (Also available from the MPS Help menu).