Comma
Development of Comma has been discontinued. Find out more.

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 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

Press 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

The 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:

Back/forward

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. Ctrl+Alt+Right works 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.

Find usages

The 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 Foo::Bar::Parser, then typing Parser will be sufficient to find it.

This can be used to navigate to declarations of:

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 will suffice.

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:

Previous/next class, method, sub, attribute, etc.

Alt+Up and 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 Alt+Down.

Next/previous problem

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 F2/Shift+F2.

Structure view

When editing Raku 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.