Shortcut to type |>?

The piping operator |> is very useful, especially when working in the REPL. However I do not find it convenient to type, it requires some finger gymnastic and it’s not very fast. Maybe it is the case because I have a french keyboard.

Does anyone knows a VSCode plugin that creates a shortcut to insert it ?

Thanks <3

2 Likes

I map it to ctrl-shift-m which is how RStudio maps %>%

Ha sweet, how do you do that ?

Hard to describe but google how to map keyboard shortcuts vscode

For future reference:

Adding the following in the keybindings.json file works in editor but does not in the REPL.
Tutorial:

[{
    "key": "ctrl+shift+m",
    "command": "type",  
    "args": { "text": "|>" },
    "when": "editorTextFocus && editorLangId == 'julia'"
},{
    "key": "ctrl+shift+m",
    "command": "type",
    "args": { "text": "|>" },
    "when": "terminalFocus && terminalProcessSupported"
}
]
12 Likes

Works perfectly. Also, I made one that inserts the @pipe operator as well.

@HenriDeh, do you have know if now the shortcut command for the pipe will work in the REPL? I have been trying to make it work, but it’s been to no avail. Please let me know if you know a way — thank you.

I quickly gave up on using this. As far as I can remember it did not work reliably and ended up being more time consuming than typing the symbols normally.

2 Likes

Thanks, HenriDeh.

Maybe have a look at our new Pipette.jl – it lets you enter " |> " via double-tapping cursor-right at the end of a REPL line, or pressing [Ctrl+cursor right] anywhere on a line. (It is also now in the general registry!)

2 Likes

There are also macro-based solutions like Chain.jl and Lazy.jl that obviate the need for the |> altogether by letting native Julia syntax stand for chained/piped function calls.

Use the english keyboard layout ;)

1 Like