When 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, howver, 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 red color you know you're off the track.
Code completion (Control + Space) will be your good friend allowing you to quickly complete the statements you typed. 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.
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 pop-up dialog with options applicable to your code at the current position. Some intentions are only applicable to a selected code region, e.g. to wrap code inside a try-catch block. These are called Surround With intentions and once you select the desired block of code, press Control + Alt + T to show the list of applicable intentions.
Whenever you need to see the definition of an element you are looking at, press Control + B or Control + mouse click to open up the element definition in the editor. To quickly navigate around editable positions on the screen use the Tab/Shift + Tab key. 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 pop-up with the error message by pressing Control + F1.
The Control + Up/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.
To quickly find out the type of an element, press Control + Shift + T. Alt + F12 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 Control + H.
The Inspector window opens after you press Alt + 2. Some code and properties (e.g. editor styles, macros etc.) are shown and edited inside the Inspector window so it is advisable to keep the window ready.
|We've prepared an introductory screen-cast showing you the basics of using the MPS editor.|
|Windows / Linux||MacOS||Action|
|Control + Space||Cmd + Space||Code completion|
|Control + B||Cmd + B||Go To Definition|
|Alt + Enter||Alt + Enter||Intentions|
|Tab||Tab||Move to the next cell|
|Shift + Tab||Shift + Tab||Move to the previous cell|
|Control + F1||N/A||Display the error message at the current position|
|Control + Up/Down||Cmd + Up/Down||Expand/Shrink the code selection|
|Shift + Arrow keys||Shift + Arrow keys||Select regions|
|Control + F9||Cmd + F9||Compile project|
|Shift + F10||Shift + F10||Run the current configuration|
|Control + Shift + T||Cmd + Shift + T||Show the type of the expression under carret|
|Alt + F12||Alt + F12|| Open the expression under carret in the Node Explorer to inspect the apropriate node and its AST surroundings
|Control + H||Ctrl + H||Show the structure (inheritance hierarchy)|
|Alt + Insert||Ctrl + N||Generate...|
|Ctrl + Alt + T||Cmd + Alt + T||Surround with...|
| Ctrl + O
||Cmd + O||Override methods|
| Ctrl + I
||Cmd + I||Implement methods|
|Ctrl + /||Cmd + /||Comment/uncomment line|
|Ctrl + Shift + /||Cmd + Shift + /||Comment/uncomment with block comment|
|Ctrl + X/ Shift + Delete||Cmd + X||Cut current line or selected block to buffer|
|Ctrl + C / Ctrl + Insert||Cmd + C||Copy current line or selected block to buffer|
|Ctrl + V / Shift + Insert||Cmd + V||Paste from buffer|
|Ctrl + Z||Cmd + Z||Undo|
|Ctrl + Shift + Z||Cmd + Shift + Z||Re-do|
|Ctrl + D||Cmd + D||Duplicate current line or selected block|
Please refer to the Default Keymap Reference page for a complete listing of MPS keyboard shortcuts (Also available from the MPS Help menu).