I make tools to help people create wonderful things.


MonoDevelop Tips: Moving Lines

To move lines around in the next editor, use the Alt-Up command to move the current line or current selected lines up, and use the Alt-Down command to move the lines down. If the language addin supports it, the lines will be re-indented to match the context when they move in and out of scopes.

This is incredibly useful for changing the order of statements.

MonoDevelop Tips: Subword Navigation

Most users are familiar with word navigation, for moving the caret to the next or previous word: Control-Left/Control-Right on Windows and Linux, and Opt-Left/Opt-Right on Mac. A previous post discussed the different modes for word breaking.

A less well-known features is "subword" navigation, which is very similar, except that it breaks in more places, such camelCase boundaries within words and underscores within identifiers. This is really useful for modifying parts of identifiers precisely. The keybinding is Alt-Left/Alt-Right on Windows and Linux, and Control-Left/Control-Right on Mac. As with word navigation, they can be combined with the Shift modifier to modify the current selection range.

MonoDevelop Tips: Navigate To Files and Types

If you know the name of a type or file and want to go straight to it without having to dig through the solution pad and file contents, the Navigate To... command is your friend. This command can be activated with Ctrl-, on Windows or Linux, and Ctrl-.on Mac, or from the Search->Navigate To.. menu. It opens a window that shows a list of all the files, types and members in the solution, and you can filter and search these items using the same substring matching that the completion list uses. When you find the one you want, hit enter and you will be taken straight to it.

The Navigate To... dialog

MonoDevelop also has Go To File and Go to Type commands, which behave the same way but are restricted to only showing files or types respectively. These predate the Navigate To command, and although its functionality is a superset of both of the older commands combined, they have been kept around because they're noticeably faster for extremely large projects.

MonoDevelop Tips: Word Breaking

There are various places where the MonoDevelop text editor needs to understand where words begin and end, for example, when you use control-left/right to move the caret (alt-left/right on Mac). We refer to this as "word breaking". Unfortunately, word breaking behaviour differs between OSes, and word breaking is often intended for text, not code. In addition, people become used to particular kinds of word breaking. For these reasons, we allow users to change MonoDevelop's word breaking mode in Preferences->Text Editor->Behavior.

This mode is like the native behaviour on Windows, breaking on transitions between whitespace, alphanumeric spans and punctuation. Has tweaks to make it more coding-friendly, such as not breaking on underscores within identifiers.
Mimics the behaviour of emacs. Words last until punctuation or the end of the next block of whitespace. This is similar to the native behaviour on Mac and Linux (GNOME).
Like Emacs mode, but with some tweaks to make it more coding-friendly, such as not breaking on underscores within identifiers. This is the default word breaking mode.

In addition, the vi input mode has its own word breaking mode that mimics the behaviour of vim.

MonoDevelop Tips: Completion List Categories

When using code completion to explore a new API, it's often useful to know where in the type hierarchy members are defined. For example, when looking for things you can do with a button, the members on the button are more interesting than the members on its superclasses. MonoDevelop makes it easier to do this with a featured called categorized mode. The completion list can be toggled into categorized mode using Ctrl-Space, and will stay in this mode until it is toggled off. While in this mode, items may be be grouped by the completion engine into categories, depending on context. For example, when listing members of types, they will be grouped by the class on which they're defined. Other groupings may be added in future.

Completion list categories

When navigating the list with arrow keys, you can jump directly between groups using Shift-Up and Shift-Down. If the list is not in completion mode, these combinations will toggle it on.

Completion mode is not the default behaviour because it makes the ordering and filtering of the list less straightforward.

MonoDevelop Tips: Workspace Layout

The MonoDevelop workspace consists of a central document surrounded by pads containing complementary information, tools and navigation aids. Pads can be accessed from the View->Pads and View->Debug Windows menus, and closed when they are not needed. They may be assigned keybindings, which will open the pad if necessary then bring keyboard focus to it. Pads may also be opened automatically by various commands, such as the "Find in Files" command, which opens a pad of search results.

Arranging Pads

You can drag pads around to arrange them however is most useful to your workflow. Pads can be docked on any side of the document editor, or adjacent to any other pad. If a pad is docked in the same position as another pad, tabs will be added to enable you to switch which of the two pads is visible.

You can even undock pads and move them to float beside MD or on another monitor. Pads that you use less frequently but still wish to be easily accessible can be "auto-hidden" using the "-" button at the top right of the pad. Auto-hidden pads are shown as a little indicator at the side of where the pad was previously docked, and when you hover over this indicator, the pad will be shown again. When the mouse and keyboard focus leaves it, it will hide again.


Which pads are is useful is something that's generally dependent on the current context. For example when debugging, it is useful to have the debugger pads for viewing the stack, locals, etc. When using the visual designer, the toolbox and property grid pads are very important. For this reason, the state of the open pads is represented by a layout, and you can switch between layouts to suit your current needs.

Layouts are very simple. There is always one active layout, and any changes you make to the pads change only the active layout. The current active layout can be changed using the list in the View menu, or the Layouts combo box in the toolbar. A new layout can be created using View->New Layout.

There are several built-in layouts that MonoDevelop switches between automatically based on the current context. The Default layout is shown when MD opens, and when a single single is loaded. The Solution layout is activated while a solution is open. The Debug layout is activated while debugging. There is also a GUI Designer layout that can be activated while using the GTK# designer, but this is optional, and an be enabled in Preferences->Visual Style->GTK# Designer.

MonoDevelop Tips: Document Switcher

The document switcher is a quick way to switch focus between open documents and pads using the keyboard. It's activated by the Ctrl-tab or Ctrl-shift-tab combinations, and remains open as long as Control remains held down. While it's open, you can change the selection — up arrow or shift-tab moves the selection up, down arrow or tab moves the selection down, and the left and right arrows move the selection between the pads and documents lists. When you have selected the item you want, release Control, and it will be selected.

The document switcher

The documents list is sorted by which have been most recently used, and when the dialog is opened, the first document it selects is the item after the current active document, i.e. the document that was focussed before it, since it's assumed that you don't want to switch to the current document. However, this also make it very easy to switch between a few documents with minimal keystrokes.

MonoDevelop Tips: Suggestion Mode

The default mode of the code completion list is to complete the symbol that's being typed. Whenever the completion engine can determine that you are typing an existing symbol (such as a type name, variable name or member name), it automatically triggers the completion list and populates it with all the values that are valid at that point. As you type while the list is open, the list's selection updates to match what best fits what you're typing, and you can manually change the selection using the up/down arrow keys. When you press space, enter, tab, or any punctuation, the completion list "commits" the selection into the document, so you don't have to type the rest of the word manually. This is incredibly useful when you get used to it.

Sometimes the completion engine cannot provide a complete list of valid values, for example when you are defining a lambda at the point that you pass it to a method. In such cases, when you need to type a value that's not in the list, it would be very irritating for the list to commit its best match and overwrite what you're typing. Instead, the completion list goes into suggestion mode.

In suggestion mode, the selection highlight in the list is a rectangle around the selection, not a solid block. When the list is in suggestion mode, it will only commit on tab or enter, so you won't commit accidentally while typing a word. If you use arrow keys to change the selection, the list will go back into completion mode and the highlight will become solid.

The completion list in suggestion mode

Some users like to write code out of order, for example using symbols that don't yet exist, and then defining them symbols later, or writing code that does not parse correctly and fixing it up. Completion mode really makes that style of coding hard to do. The answer is a command that toggles the list into suggestion mode. You can access it via the Edit->Toggle Completion Suggestion Mode menu item, or the Alt-Shift-Space key binding. Once the list is toggled into suggestion mode, it will stay that was until you toggle it back. This it useful because you can switch back and forth as it suits you.

MonoDevelop Tips: Fullscreen Modes

Sometimes it's useful to be able to focus only on your code without the distractions of the pads and the rest of your desktop. MonoDevelop has two ways to make this easier.

The Maximized View can be toggled by double-clicking on the document tab, or using the context menu on the document tab and selecting Switch maximize/normal view. When in maximize view, all open pads are auto-hidden at the sides of the MonoDevelop windows, and all toolbars are hidden (everything in the toolbars is also accessible from the menus).

The Fullscreen View can be activated using the View->Fullscreen menu command. This makes the MonoDevelop window take up the entire screen, hiding the taskbar and the window border.

Both view modes can be used together to maximize the document area as much as possible.

MonoDevelop Tips: Import Type

One of my favourite features that we added to MonoDevelop 2.4 is the "import Type" command. It is accessed using the keybinding Ctrl-Alt-Space, and shows a list of all types in all namespaces in all referenced assemblies:

The completion list for the Import Type command

You can use our completion list filtering to find the type you're looking for, then, when you commit the selection from the list, MonoDevelop automatically adds the "using" statement to the file. For example, using StringBuilder is as easy as StrB even if you don't yet have using System.Text; at the top of the file.


Subscribe to Journal