Tinkering with Raspberry (and other things)

Edit Source Code Remotely

Recently I caught myself juggling with 5 open terminal sessions simultaneously. Four windows were showing different source files from a project I am working on and the fifth terminal was the commandline from where I started compilation and ran the programs. This was really annoying because even on my 27″ monitor the terminal windows took all the space and I frequently had to change desktops and so on.

So the question arose: “Can’t this be done in a more efficent way?”

Well, apparently it can be done. My first thought was to use the X-server remotely via screensharing but I gave up on this quickly. The Raspberry Pi just has not enough power to run x-windows smoothly when there are to many open windows. And it surely hasn’t enough power to run an IDE (Integrated Development Environment). And using the joe or nano editors on longer source files is not very comfortable.

On my Mac I am using Komodo Edit as my editor of choice. It is very comfortable and supports syntax highlighting for all the languages I use. And it’s completely free and running on Mac, Windows and Linux. I never paid much attention, but Komodo Edit supports remote editing. Exactly what I have been looking for. The goal is to be able to edit the files on my Raspberry Pi remotely and in place (that means without copying them to the local machine first) and have only one terminal session open to test and run my scripts.

I suppose you have SSH enabled on your Raspberry Pi. Some hints to make life easier despite using SSH can be found in my “Basics for Beginners (part 3 – SSH)” article. Again, the things described there should only be made within a local network!

If you haven’t done, grab a copy of Komodo Edit and install it. Open Komodo Edit and directly go to “Komodo->Preferences”. Click on the “Server” entry and fill out the details according to your Raspberry Pi and network settings. It should look something like this:


Of course with the IP address your Raspberry Pi uses. Next go to “Project->New Project”, choose a name and a location where your project configuration will be saved to. For this tutorial I named my project “Blog Project”.


Now you should see a sidebar on the left of the Komodo Edit window with a “Projects” and a “Places” bar. Right click the name of your project and in the context menu select “Add->Existing remote folder“. In the next window select the server we added above and Komodo Edit should connect and show you the contents of the home directory. Just like here:


I will choose Workplace/Python for the demo. After clicking “Select” this window will close and the name of the selected folder will appear right under your project’s entry in the sidebar:


Right click the folder name and select “Show in Places”. All files and subdirectories within the selected folder will now show up under the “Places” bar on the left. And yes, these are the files on your Raspberry Pi. They are not copied locally!


Now let’s see if we can edit one of those files. Just double-click on one file and it will open in the editor. For testing I simply added a comment as a first line. Click the “Save” icon and open the exact same file directly on your Raspberry Pi. Pure magic. The changes are there.

Adding a new file is as simple. Just remember NOT to use “File->New->New File” command from the menu bar. Instead, right click somewhere inside the “Places” area and select “New File” from the context menu. A window will pop up, asking you for a filename. The same works with folders. Take a look at the next screenshot. On the right side is a terminal window. I listed all contents, the remotely added the file “TEST.TXT” and did an “ls -al” again. File is there (last line). Whoooaaa!


However, there is one thing to remember. On the Raspberry Pi I had my editors configured to always save a backup of files I edited. Of course, Komodo Edit does this too. However, the backup files are stored locally. I have not yet found a way to store remote file backups remotely. So for now I have decided to manually make a copy before I am going to edit the files remotely.

But it is still more convenient to be able to edit files with a comfortable editor on a fast machine. The only thing that need to be done in a SSH-session on the Raspberry Pi is testing. Very cool, I think.



Comments are closed.