Keyboard Navigation in Nuclide
Note that all of these shortcuts are for Mac. You can use the key finder (described near the end of this article) to determine the linux/windows equivalents:
This is the core of understanding source code. If you remember one thing from this post, this is it:
Shortcut | Description |
---|---|
cmd-alt-enter | Goto Definition of the symbol under the cursor |
Combined with Goto Definition, this is the power tool for understanding source code. Use Goto Definition repeatedly to investigate a sequence of calls in a call stack, then use the Navigation Stack to go back (and forwards again) to where you came from.
These shortcuts are the source code equivalents of the forward/backwards buttons in your web browser.
Shortcut | Description |
---|---|
ctrl-,/. | Forwards and backwards in the navigation stack. |
After writing code, the first thing you want to do is fix your compile errors. Get used to doing this without the mouse.
Shortcut | Description |
---|---|
alt-</> | prev/next Diagnostic |
alt-ctrl-</> | first/last Diagnostic |
cmd-alt-</> | prev/next Diagnostic Trace. Navigate through the multiple locations reported in complex Hack/Flow diagnostics. |
alt-shift-D | Show/hide the Diagnostics Panel |
This is another area where its easy to fall back to using the mouse.
Shortcut | Description |
---|---|
cmd-shift-\ | Reveal the current file in the file tree |
ctrl-0 | Toggle focus to/from the file tree |
cmd-t | Open file by name (and more) |
cmd-w | Close the current file |
cmd-\ | Show/hide the file tree. Useful on smaller screens. |
ctrl-alt-shift-X | Copy relative (to the current project) file name to the clipboard. |
ctrl-shift-X | Copy absolute file name to the clipboard. |
The combination of the first 2 is convenient for opening a file in the same dir as the current file. The sequence is:
- reveal
- toggle focus
- arrows - select nearby file
- enter - open selected file
Also, you can search for a file within a subdirectory fro the file tree. Focus the file tree (ctrl-0), select the directory you want to search in using arrows. Once a directory is selected, typing any characters will search for files within that directory.
Note: the one major thing missing is opening a file in Nuclide given an absolute path. Hackathon project anyone?
Moving the cursor around efficiently within a file.
Shortcut | Description |
---|---|
arrows | move by character/line |
alt-arrows | move by word/paragraph |
page up/page down | move by screen fulls |
cmd-arrows | move to beginning/end |
ctrl-m | Navigate to matching bracket (), [], {} |
Note you will want to add paragraph movement to your atom key map file.
'atom-text-editor':
'alt-up': 'editor:move-to-beginning-of-previous-paragraph'
'alt-down': 'editor:move-to-beginning-of-next-paragraph'
'shift-alt-up': 'editor:select-to-beginning-of-previous-paragraph'
'shift-alt-down': 'editor:select-to-beginning-of-next-paragraph'
See the end of this article on opening your Atom keymap file.
I'll usually have 2 panes open when I'm editing code. My left pane will contain the file(s) I'm editing, while the right pane will contain tabs for related code files.
Shortcut | Description |
---|---|
cmd-k arrow | Move the current editor to a new pane in the given direction. |
cmd-k cmd-arrow | Move focus to the pane in the given direction. |
cmd-{/} | Focus the prev/next Tab(editor) within the current pane. |
cmd-shift-T | Re-open the last closed tab |
I highly recommend the spectacle app for OSX. If you use a Mac download it and pay this man for all the time he will save you.
Spectacle gives you keyboard shortcuts for positioning the current window on your screen.
Shortcut | Description |
---|---|
cmd-alt-f | Resize the current window to full screen |
cmd-alt-arrow | Move and resize the current window to fill half of the screen |
ctrl-alt-arrow | Move and resize the current window to fill thirds of the screen |
Another option is Moom.
Atom is built around the concept of a command which can be mapped to keys. Want to tune your keyboard shortcuts or figure out what a key does, these commands are for you.
Shortcut | Description |
---|---|
cmd-. | Show/Hide a panel at the bottom of the Atom window which displays the key hit and the commands mapped to that key. |
cmd-shift-P | Fuzzy search through all of the commands in Nuclide and Atom. |
cmd-, | Show Atom Settings |
cmd-alt-, | Show Nuclide Settings |
To remap a key you will need to edit your ~/.atom/keymap.cson
file. You can
open your keymap file with:
- cmd-, to show Atom Settings
- select Keybindings
- select the highlighted
your keymap file
in the help text