-
Notifications
You must be signed in to change notification settings - Fork 4
/
vsCode.Rmd
79 lines (68 loc) · 2.03 KB
/
vsCode.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
title: "Visual Studio Code"
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
echo = TRUE,
error = TRUE,
comment = "",
class.source = "fold-show")
```
# Tips and Tricks
1. You can view the source code side-by-side with the Preview (after selecting the code type in the bottom right):
![Visual Studio Code](images/vsCode.png)
1. To wrap code around the selected text (https://stackoverflow.com/a/73344832/2029527; archived at https://perma.cc/P5JA-7DBC):
1. Press `Ctrl`+`Shift`+`p`
1. Type and select "Open Keyboard Shortcuts (JSON)"
1. Add the following item:
```
[
{
"key": "alt+shift+e",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "<TEXT-BEFORE>$TM_SELECTED_TEXT</TEXT-AFTER>"
}
}
]
```
1. Save the `keybindings.json` file.
1. Select the text you want to wrap, and press `Alt`+`Shift`+`e`
# Example Code Snippets
## Template
```
[
{
"key": "alt+shift+e",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "<TEXT-BEFORE>$TM_SELECTED_TEXT</TEXT-AFTER>"
}
}
]
```
## `\begin{equation}...\end{equation}`
```
[
{
"key": "alt+shift+e",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "\\begin{equation}\n$TM_SELECTED_TEXT\n\\end{equation}"
}
}
]
```
# Connect to `R`
Follow the instructions here to connect `VSCode` to `R`:
https://stackoverflow.com/a/66069540/2029527 (archived at https://perma.cc/FCF5-26BT)
1. Install `R` using the inital setup instructions described here: https://devpsylab.github.io/DataAnalysis/R.html#setup
1. Install the `R` extension for `VSCode`
1. Go into the `R` extension settings
1. Set the `R` path to the path of your `R` installation:
- e.g., `C:\\R\\R-4.3.1\\bin\\x64\\R.exe`
1. Set the `Rterm` path to the path of your `R` installation
- e.g., `C:\\R\\R-4.3.1\\bin\\x64\\Rterm.exe`