# Julia Win10 - REPL and OhMyREPL - neat trick for nice copy/past - works in VsCode, WT, etc

**URL:** <https://discourse.julialang.org/t/julia-win10-repl-and-ohmyrepl-neat-trick-for-nice-copy-past-works-in-vscode-wt-etc/67662>\
**Category:** General Usage\
**Tags:** windows, repl, vscode\
**Created:** [September 3, 2021, 5:56pm UTC](https://discourse.julialang.org/t/julia-win10-repl-and-ohmyrepl-neat-trick-for-nice-copy-past-works-in-vscode-wt-etc/67662 "2021-09-03T17:56:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylvain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ylvain/32/28495_2.png) [@ylvain](https://discourse.julialang.org/u/ylvain)\
**Post date:** [September 3, 2021, 5:56pm UTC](https://discourse.julialang.org/t/julia-win10-repl-and-ohmyrepl-neat-trick-for-nice-copy-past-works-in-vscode-wt-etc/67662/1 "2021-09-03T17:56:36Z")

</div>

First all credit goes to @ [MarcMush](https://discourse.julialang.org/u/MarcMush) for the idea in [this thread](https://discourse.julialang.org/t/pasting-long-lines-into-the-repl-takes-too-long-in-win10/59995) (Apr 25).

I only quasi-repost because there’s an added step for making it works with VsCode and because I stumbled on it after having be bogged down by the issue for quite some time… maybe useful to others.

_What this solves_: slow past of multiline text into std REPL, **very** slow past and broken indentation into OhMyREPL.

1. Tweak your `startup.jl` to include the snippet below. This defines a keybinding for pasting using Julia `clipboard()` function. In VsCode it is bound to `Ctrl+V` and replace the standard past (emulate so called bracketed past)
2. For VsCode integrated “Julia REPL”, add the snippet below to your keybindings.json - command `Preferences: Open Keyboard Shortcut (JSON)`

_Result_: instant cut/past of large code text, with correct indentation and colors. By Ctrl+V in VsCode and by Ctrl+N in other terminals.

By the way… if you like the command line… I strongly recommend that you install [Windows Terminal](https://docs.microsoft.com/en-us/windows/terminal/). Dev by Microsoft, on GitHub, open source, installed by the store. Shortcut “wt”. Provide a full \*nix grad terminal with true tty backing, tabs, panes, etc… You can add profiles to have bash (from e.g. Git-for-Windows) and Julia.

Since Win10 the awful `conhost` (the win95 non-equivalent of unix tty) has been replaced by contty. So now Windows actually _has_ true full featured tty. With WT you get an xterm over this tty. The new tty is used by powershell and new cmd… but currently not by Julia (julia.exe default install still use conhost, so it’s awful, running it in WT should be the default).

## .julia/config/startup.jl

```julia
if isinteractive()
    # ......

    using OhMyREPL
    # your usual config of here. No need to change it...
    colorscheme!("CustomColors")
    enable_autocomplete_brackets(false)
    enable_highlight_markdown(true)
    # fuzzy history search. Does not work in git-bash mintty, but work well in VSCode term & WT
    enable_fzf(get(ENV,"TERM_PROGRAM","") != "mintty")

    # Here is the nice idea of MarcMush
    using REPL
    atreplinit() do repl
        if repl isa LineEditREPL
            bind = !haskey(ENV,"SHELL") && get(ENV,"TERM_PROGRAM","") == "vscode" ? "V" : "N"
            printstyled("Bind Ctrl+$bind: Past Code Block\n"; color=:blue)
            Base.active_repl.interface = REPL.setup_interface(Base.active_repl; extra_repl_keymap = Dict{Any,Any}(
                "^"*bind => (s, data, c) -> 
                    begin
                        REPL.LineEdit.edit_insert(REPL.LineEdit.buffer(s), REPL.InteractiveUtils.clipboard())
                        OhMyREPL.Prompt.rewrite_with_ANSI(s)
                    end
            ))
        end
    end

   # ......
end

```

## keybindings.json

```json
   // in ...\AppData\Roaming\Code\User\keybindings.json
   // remove Ctrl+V keybind for the all terminals
   {
      "key": "ctrl+v",
      "command": "-workbench.action.terminal.paste",
      "when": "terminalFocus && terminalProcessSupported"
   },
   // re-add Ctrl+V keybind for the all terminals BUT for the Julia REPL session
   {
      "key": "ctrl+v",
      "command": "workbench.action.terminal.paste",
      "when": "terminalFocus && terminalProcessSupported && !isJuliaREPL"
   },

```

---

<div class="post-metadata">

**Author:** ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Post date:** [May 4, 2022, 9:00am UTC](https://discourse.julialang.org/t/julia-win10-repl-and-ohmyrepl-neat-trick-for-nice-copy-past-works-in-vscode-wt-etc/67662/2 "2022-05-04T09:00:09Z")

</div>

Hi, is this really working?  
According to

> [@Startup.jl not loading](https://discourse.julialang.org/t/startup-jl-not-loading/29798/2):
>
> isinteractive() is false when loading startup.jl (by default)

the `isinteractive()` is false in the startup.jl, so this never executes. I have tried it.

---

<div class="post-metadata">

**Author:** ![ylvain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ylvain/32/28495_2.png) [@ylvain](https://discourse.julialang.org/u/ylvain)\
**Post date:** [May 5, 2022, 6:45am UTC](https://discourse.julialang.org/t/julia-win10-repl-and-ohmyrepl-neat-trick-for-nice-copy-past-works-in-vscode-wt-etc/67662/3 "2022-05-05T06:45:21Z")

</div>

Yes its working 😉  
You have to tell julia that you intend to use it in interactive mode, that is you have to pass the `-i` option.  
This is what `isinteractive()` do: it tests if `-i` was passed to julia.  
_Note that vscode will pass `-i` to the julia process it spawns when opening a REPL._
