Neovim + Tmux sending a full function to the REPL like VSCode

Hi Julians,

When I have to write a Julia function and I want to test with the REPL I have to select all the block of code or send parts of this or make sure that there is no blank space between lines to do it at once, but I consider the way is doing it in Visual Studio Code is the right approach.

Is there a way to select an entire function and send it to the REPL, by using the cursor inside the function at once and independently from the position the cursor is in this one?

Image as a reference:


Run your Julia REPL in a neovim terminal. Use one of the many [neo]vim plugins that sends selected text directly to the terminal. Use treesitter, that lets you select the Julia function your cursor is in, with a simple shortcut. Done!


E- I realize now you’re looking for sending the full function at once. I don’t have that implemented, so I’m missing the functionality you’re looking for. LeePhillips’ comment should cover the part of extracting the function. Leaving the rest of my comment below

I wanted to roll my own REPL integration recently and was working on this. I bound <C-m> to send to the active Julia REPL and use code here: dotfiles/julia-repl.lua at master · SBuercklin/dotfiles · GitHub

The config needs a lot of cleaning up and makes a lot of implicit assumptions around how I use neovim, so I’m not sure I would recommend using it directly.

I recently found out about ToggleTerm which looks like it replicates a lot of the behavior I have in that file, and more, with better practices. I’d suggest looking at that, I think what you’re looking for is here under sending lines to the terminal: GitHub - akinsho/toggleterm.nvim: A neovim lua plugin to help easily manage multiple terminal windows


I built a tool to extract the most toplevel statement under the cursor and evaluate it on a Julia REPL using the Julia tree-sitter grammar. The goal is to replicate the experience of the VScode extension so it also shows the result of the evaluated expression next to the sent node.


The Julia REPL communicates with the neovim instance via sockets so it can also work when the REPL is launched inside another tmux pane but that can require a bit of work to make it work. I have bindings to open the Julia REPL in the builtin neovim terminal as @LeePhillips suggested so I never tested the tmux usecase. If you are interested the code is at Neige.jl. Feel free to only take the relevant part needed (code extraction).


This is the straightforward solution I could see (GitHub - nvim-treesitter/nvim-treesitter-textobjects). You can set the cursor inside the function, use the visual mode ‘v’ and finally use ‘af’ (all function I guess) to select the block… Then ctrl-c + ctrl-c if you are using vim-slime. That’s it.

Thank you Lee!

Where’s this tool at!

1 Like