While experimenting with code, it can be very useful to comment a block of code
To comment a block of code, use select Toggle Line Comment(s) from the context
menu, or use the Control-Alt-C keybinding on Windows and Linux. If the current
line is commented, it will be uncommented, or if it is not commented, it will be
commented. If multiple lines are selected, then if any are not commented, they
will all be commented. If all are commented, they will all be
It’s easy to increase or decrease indentation of a block of code in MonoDevelop.
Hit the Tab key while there is a selection, and the selected lines’
indentation will be increased. Similarly, hit Shift-Tab and the indentation
will be decreased.
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.
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
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.
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.
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
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 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.
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
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.