Code navigation in Comma
This document features a range of keyboard shortcuts. Sometimes, however, they may have been mapped
to something by the window manager. For example,
Alt+F7 is used for Find usages in Comma, but on
Ubuntu this key combination is mapped to move window. To resolve such conflicts, either:
- Go to the Settings dialog (found on the File menu) and then to the Keymap section. Choose different, available, key combinations.
- Unmap them elsewhere, so that they will work on Comma.
Go to a line number
To go to a particular line in the current file, press
Ctrl+G, type the line number, and press enter.
Search/navigate declarations in the current file
Ctrl+F12 to bring up a list of declarations (packages, subs, methods, attributes) in the current
file. Filter elements by starting to type the letters making up their name. Use the arrow keys to navigate
to the desired element, if needed, and then press enter to jump to it.
Go to declaration
Ctrl+B keyboard shortcut takes you to the declaration of the element that your cursor is currently
placed on. For example, if your cursor is currently on a sub call, then it would take you do the sub
that is being called. This feature works for:
- Lexical variables
- Subroutines in the current file
- Subroutines imported from another module within the project
- Private methods from within the current project
- Methods with the current project in the case that we can type infer the invocant
- Rules in a grammar
- Types in the current project
- The module name in a
needstatement, when the module is within the project
Often, one might use Go to declaration in order to check how the implementation of, for instance, a
subroutine looks, and then want to go back and continue editing. The
Ctrl+Alt+Left key combination
goes back to the previous location, much like a back button in the browser.
like the forward button in a browser, returning to what you just went back from.
A related shortcut is Ctrl+Shift+Backspace, which goes back to the location of the last edit.
Alt+F7 keyboard shortcut locates all usages of a symbol throughout the current project. These
are displayed in a results panel. If you are on a declaration, then this is the symbol whose usages
will be found. Otherwise, it uses the same lookup behavior as Go To Declaration to find the declaration,
and then finds all usages of it. This means that Find Usages may be used on, for example, a call to a
subroutine in order to find all other calls to the subroutine.
Navigate to type
To navigate to a type declared within the project, press
Ctrl+N and type part of the type name. You
can type just a latter part of the name; for example, if the project has a
Parser will be sufficient to find it.
This can be used to navigate to declarations of:
- Subset types
- Enumeration types
Any type that has a global name will be presented in its fully qualified form. Lexical types will can also be found this way, and will be indicated as being lexical in nature, together with the name of their enclosing module.
Navigate to file
Ctrl+Shift+N can be used to navigate to any file within the project. Typing just part of the filename
Navigate to symbol
Ctrl+Alt+Shift+N (pressing the keys in this precise order matters) can be used to navigate to a range
of different symbols, including:
- Types (everything
Ctrl+Nwould find is included)
- Method and subroutine declarations
- Rule (
- Constant declarations
- Attribute declarations (
Previous/next class, method, sub, attribute, etc.
Alt+Down will move up and down between major declarations. For example, if in one method
and wanting to jump to the start of the next, press
Live code analysis highlights problems in the current file. Those currently on screen are underlined,
while on the right hand side of the editor, the scroll bar is annotated with the locations of errors.
One can jump between these with
When editing Perl 6 code, pressing
Alt+7 will open (or close, if already open) Structure View, which
provides an overview of the declarations in the current file. A single-click on an element there will
scroll the file to that place, and double-clicking places the cursor there for editing. To do this by
keyboard navigation, after
Alt+7 press tab, and then used the arrow keys to move up and down. The
file will scroll to the appropriate place. Press the escape key to return to the code editor.