R extension for Visual Studio CodeA Visual Studio Code extension provides support for the R language for R 3.2+. Features include syntax checking, completions, code formatting, formatting as you type, tooltips, linting. Supported platforms
Prerequisites
Quick startOpen the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux) and type 'R:' to see list of available commands and shortcuts. Syntax checkSyntax check is performed as you type or when opening a file. Look for red squiggles. Problems are also reported in the FormattingExtension provides ability to format document or selection. Formatting options are available in the Automatic formatting (as you type)The editor can format code after you type Enter, ; or }. You can control the feature via LintingFunctionality is close to lintr. However, you do not have to run linting explicitly, it happens as you type. By default it is disabled, you can enable it by setting Execute in terminal/source fileUse Shortcuts and snippetsExtension provides shortcuts for You can either type Snippets file can be found in Thanks to @jackbrookes for suggestions and snippets. Remoting and WSLThe extension does work in WSL. However, output windows cannot be displayed since UI does not translate over remote connection. There is limited support for plotting though. Remoting like Using R on Apple ARM siliconMake sure you install VS Code for OSX for ARM. You may have to download it separately since if you have had VS Code installed on M1 before ARM build became available and kept upgrading it, it is probably still x64. The extension by default uses ARM version with R 4.1 or higher. However, if you need to use Intel build of R such as when you may be using native packages not available for ARM, you can select x64 R from the list of interpreters - such as pick '4.1' and not '4.1-arm64'. Use PlottingPlots typically appear in external R windows. However, there is support for internal Remember though that Terminal window and internal R session are not connected. Executing code in Terminal and then attempting plot the result via internal session won't work. With remote sessions, you can execute code in Terminal, save results into a file, then execute plotting in internal session providing results from the file. ) Using custom R executable in terminalYou can set Known issuesR session in the editor does not automatically pick up new packages installed in the terminal. You may have to reload the window for the session to pick up newly installed modules. TroubleshootingR Interpreter not found Try using Not currently supported
Bug reportsPlease file issues at the project GitHub Disclaimer
|