Setup VSCode for MOOSE code and input file development

VSCode autocompletion in MOOSE input files.

Autocompletion for MOOSE input files.

Outlines for MOOSE input files.

MOOSE input file formatting.
VSCode is a text editor developed by Microsoft with a flexible plugin structure. VSCode supersedes Atom. To customize VSCode for MOOSE development the MOOSE Language Support extension has been developed.
Setting up VSCode
Installation packages can be downloaded for Mac, Linux, and Windows operating systems from the VSCode website. The editor has an automatic update system for both the core editor as well as the installed extensions.
First Steps
On macOS, Start VSCode for the first time, then press
F1
(orCmd-Shift-P
) and typeShell Command: Install 'code' command in PATH
. Press enter. This activates thecode
shell command for use from a terminal.On Linux the shell command is automatically installed.
Close VSCode. From now on we will _only_ start it from the command line using the
code
terminal command ensuring that VSCode sees the full MOOSE build environment.
Commands
Note that letters shown upper case in commands do not mean literal upper case. You do not have to press shift when typing these letters. This is just the notation (confusing I know). A good reference for hotkeys can be found here. Linux hotkeys can be found here. The hotkeys we give below assume MacOS.
Cmd-Shift-P
opens the command palette. Every available command can be accessed by typing a few letters here. The dropdown list shows the keyboard shortcuts.Cmd-P
opens a file anywhere in the current project tree (i.e. below the directory in which you issued thecode .
command. No need to know the precise path or even the precise spelling of the filename!Cmd-[
Decrease indent (Outdent)Cmd-]
Increase indent (Indent)Cmd-F
FindCmd-Option-F
Find and replace -Enter
Find next match without replacement -Ctrl-Enter
ReplaceCmd-Option-Left/Right Arrow
Tab between open editor files as ordered on the screenCtrl-Tab
Tab between editor files in the order they were openedShift-Option-Drag Mouse
Rectangular text selectionOption-Repeated Clicks
Place multiple cursors (one per each click)Cmd-S
Save current fileCmd-J
Toggle terminal visibilityCtrl-`
Toggles on terminal visibility if not currently visible. Switch focus to terminal if focus is elsewhere. If focus is already on terminal, toggles off terminal visibility
Cmd-1
Change focus to code editorCmd-\
Split screen verticallyCmd-W
Close current file. If last file in split, then split will disappearCtrl-G
Goto lineCtrl-N
Move cursor to next lineCtrl-P
Move cursor to previous lineCtrl-E
Move cursor to end of lineCtrl-A
Move cursor to beginning of lineCtrl-K
Kill from cursor to end of lineCtrl-Y
Redo last undone action (not yank like in emacs)Ctrl-F
Move cursor to next characterCtrl-B
Move cursor to previous characterCmd-B
Toggle left sidebar visibilityCmd-Left/Right Arrow
Move cursor to beginning/end of lineOption-Left/Right Arrow
Move cursor over one word to left/rightCmd-K Cmd-M
Maximize/Unmaximize current editor groupCmd-Up/Down Arrow
Go to beginning/end of fileFn-Up/Down Arrow
Page Up/Down in fileCmd-Shift-\
Go to matching braceCtrl--
Go to previous cursor location (useful after doing things likeCmd-Click
)Cmd-L
Select current lineCmd-D
Select current word. Repeated invocations will also select next matches of that word. This is useful if wanting to edit multiple occurrences of the word without going through the Find/Replace focus.
Focuses
findInputFocussed
Cursor is in the Find box (note that cursor in the Replace box of the Find and Replace box does not count)editorFocus
Cursor is within the code editor
Extensions
The following extensions should be installed to effectively develop MOOSE based codes and edit MOOSE input files using VSCode
MOOSE Language Support: Syntax highlighting, automatic indentation, document outlines, mouse hover info, formatting, and auto-completion for MOOSE input files, C++ code snippets for all MOOSE systems, and highlighting of select MOOSE C++ types.
C/C++ Extension Pack installs a set of extensions to support C++ code navigation, syntax highlighting, etc.
Recommended settings
The following settings are recommended to pass the MOOSE GitHub CI pre-checks:
The editor.formatOnSave
, files.insertFinalNewline
, and files.trimTrailingWhitespace
options are helpful to avoid failing the automated code check in MOOSE's test suite. The C_Cpp.default.includePath
settings ensure that includes installed with Conda are found. The _Atom One Dark_ theme is available as an extension and provides the familiar Atom colors. GitLens is an extension that provides extensive git integration.