Disclaimer: this question was posted prior to unix.se but, as recommended by a moderator, was reposted here. The original question was not (yet) deleted since some good comments were posted there.

I'm currently using neovim as my IDE for writing and executing GNU R-code (using the Nvim-R plugin, which serves as my REPL), which works great on my local machine. When having higher workloads or demands, I'm ssh-ing into a remote machine, installing my nvim plugins and running nvim as a "local" application on the server.

Recently I realized that Emacs has the ingenious TRAMP mode (Transparent Remote Access, Multiple Protocols), which allows to not only open files remotely, but also execute commands on a remote machine. From what I understand this means that I could use Emacs as a REPL (e.g., using ESS), writing code using my local Emacs-instance, but executing it on a remote machine where I have GNU R installed (see also ESS processes on remote computers).

I'd be interested to know if something similar exists for vim or neovim. I'm aware that I can edit files remotely using

vim scp://USER@SERVER:PORT//absolute/path/to/file


:e scp://USER@SERVER:PORT//absolute/path/to/file

but from what I understand this actually creates a temporary copy of the file on my local machine; when running my Nvim-R-REPL this opens the working directory locally on /tmp/something.

I thought about experimenting with vim-slime, repl.nvim or neoterm, but I'm unsure if I would be able to replicate an Emacs-like experience.

Any ideas? Has anybody achieved something similar?

  • 1
    Welcome to Vi and Vim! – filbranden Sep 11 '20 at 21:28
  • 1
    I’ve inlined the links with a bit of markdown, which you can use to format most things on Stack Exchange. I’m not aware of anything like this currently, but would love to be. – D. Ben Knoble Sep 11 '20 at 22:49
  • @b-ben-knoble: thanks a lot! – n0542344 Sep 13 '20 at 8:31
  • @d-ben-knoble: By the way: I wanted to add other tags (like I did at the original post: [emacs] [vim] [remote] [ssh] [r]) but wasn't able to do so since some of the tags don't (yet?) exist on vi.se. If you think those tags would make more sense for someone searching for that question I'd be grateful for an update. – n0542344 Sep 13 '20 at 8:40

I still haven't found the perfect solution, but one that works for me reasonably well: by using vim-slime (which is written in only vimscript).

In my config-file (~/.config/nvim/init.vim or ~/.vimrc), I'm using the following line(s):

let g:slime_target = "neovim"
"let g:slime_target = "vimterminal"
"let g:slime_target = "screen"
"let g:slime_target = "tmux"

Only one of them is needed. The first line is used for neovim, but if I'm using vim I use the second one (uncommented). In my workflow I'm ssh-ing into a remote machine, then open the file I want to use (e.g. my script.R or list_of_commands.sh), then create a :vertical split and subsequently open a :terminal, where I can then run e.g. my GNU R-interpreter or a bash. If one prefers to use a terminal multiplexer, the new split can be created using either screen (with Ctrl-a | Ctrl-a l Ctrl-a c) or tmux (with Ctrl-b %) and have the appropriate line from above (uncommented) in the config-file.

When I then invoke the :SlimeSend-command (abbreviated with Ctrl-c Ctrl-c, so the same key-combination has to be pressed twice), the text I'm currently having my cursor on is selected to be send to the target (which, when the configuration is correct and your split is already present, is written in correctly by default).

That might not be as elegant as TRAMP in Emacs, but it works. But if anyone has ideas for improvement, don't hesitate to suggest them!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.