はじめに
RstudioではCtrl+Shift+M
でパイプ演算子%>%
を挿入できます。
Visual Studio Codeでも同じショートカットキーで%>%
を挿入できるように設定します。
keybindings.jsonを開く
Ctrl+Shift+P
でコマンドパレットを開きます。
key
と入力すると Preferences: Open Keyboard Shortcuts (JSON)
が出てくるのでクリックします。
%>%
を登録する
JSONに下記のキーバインディングを追記します。
{
"key": "ctrl+shift+m",
"command": "type",
"args": {
"text": "%>%"
},
"when": "editorTextFocus && editorLangId == 'r'"
},
以下はkeybindings.json
の中身です。
// 既定値を上書きするには、このファイル内にキー バインドを挿入しますauto[]
[
{
"key": "ctrl+shift+m",
"command": "type",
"args": {
"text": "%>%"
},
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "ctrl+shift+enter",
"command": "workbench.action.terminal.runSelectedText"
},
{
"key": "shift+enter",
"command": "-python.execSelectionInTerminal",
"when": "editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+meta+enter",
"command": "python.datascience.execSelectionInteractive",
"when": "editorTextFocus && python.datascience.featureenabled && python.datascience.ownsSelection && !findInputFocussed && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "shift+enter",
"command": "-python.datascience.execSelectionInteractive",
"when": "editorTextFocus && python.datascience.featureenabled && python.datascience.ownsSelection && !findInputFocussed && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+shift+capslock ctrl+shift+alt+m",
"command": "workbench.actions.view.problems"
},
{
"key": "ctrl+shift+m",
"command": "-workbench.actions.view.problems"
},
{
"key": "ctrl+shift+enter",
"command": "-r.runSourcewithEcho",
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "ctrl+shift+enter",
"command": "-editor.action.insertLineBefore",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'rmd'"
}
]
以上です。