In my article on setting up a development environment on Android devices, I showed how you can install and configure Neovim, Emacs and Visual Studio Code on to the device. In this article I am going to walk through on how to use VS Code and Neovim to perform remote code development.
Remote Code Development
For both VS Code and Neovim remote code development, SSH server must be running on the remote machine. Since I have already set up OpenSSH in the previous article, I will not go through the steps here again.
Prerequisite for Visual Studio Code
VS Code Remote SSH only supports glibc based Linux distributions. Since we are using Termux on Android devices, there is an additional step for us to set up Ubuntu in Termux.
Once I get the Ubuntu prompt, I need to install OpenSSH for the Ubuntu instance.
root@localhost:~# apt-get updateroot@localhost:~# apt-get install openssh-server
Install dependant libraries required by VS Code.
root@localhost:~# apt-get install build-essential -y
Add the following line to /etc/ssh/sshd_config to allow root login.
Start sshd listening on port 8023.
root@localhost:/# mkdir -p /run/sshdroot@localhost:/# /sbin/sshd -p 8023
Change the password for root.
Visual Studio Code
I am going to use Visual Studio Code Remote Development which allows us to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment.
From within VS Code, press
Command P for macOS) type
ext install ms-vscode-remote.remote-sshto install the Remote SSH extension
ext install ms-vscode-remote.remote-ssh-editto install the additional extensions for syntax colorization, keyword intellisense, and simple snippets when editing SSH configuration files.
In VS Code, select
Remote-SSH: Connect to Host… from the Command Palette (
SSH into the device. In my case the IP address is 192.168.0.116
In case you encounter SSH time-out issue, try again.
Once connected I can see the remote folders. There is a message at the bottom left indicating that I am in a SSH session.
I can now install VS Code extensions into Termux, and also perform remote code development.
There are at least 2 options that we can use Neovim to edit files remotely.
From the computer, mount the remote folder using sshfs. The syntax is
sshfs [user@]hostname:[directory] mountpoint
Below I mount the remote folder into ~/remote folder.
# mkdir -p ~/remote# sshfs -d -p 8022 firstname.lastname@example.org:/data/data/com.termux/files/home ~/remote
Once the remote folder is mounted, I can then use nvim to edit the files.
Both Vim/Neovim come bundled with Netrw which acts as a file explorer. Type
:h netrw-nread and you can see it supports protocols like scp, sftp, http, rcp, etc. For scp, the syntax is
Since I am using password authentication, from my computer which is using Arch Linux, I need to install ssh-askpass.
# sudo pacman -S x11-ssh-askpass
Then I can use Neovim to browse a remote folder. Note the “/” at the end.
# nvim scp://email@example.com:8022//data/data/com.termux/files/home/
Do also check out the following articles.
How to Debug Running or Dockerized Python Apps
How to debug an application that may not be directly available on your own machine