Praveen’s Journal

March 29, 2008

Remote file editing on GNU Emacs using TRAMP

Filed under: General — Tags: , , — Praveen Kumar @ 7:54 am

I have been using GNU Emacs for programming for nearly 9 years now. It is exciting to keep discovering new extensions to Emacs throughout. I have heard of Ange-FTP before that can be used for remote file editing using FTP. However, I have never tried remote file editing on a local Emacs session. In most of the scenarios, I was dealing with editing files on the remote machines by invoking Emacs locally on those machines. But this time, I felt that invoking GNU Emacs (22) on my tiny VPS would be an overkill. So, I decided to try out remote file editing from a local Emacs session.

Even though I knew that I can do this with AgneFTP, I didn’t really care to read the info about it as I don’t run FTP on my server. The first hit on Google when I searched about remote file editing on Emacs was TRAMP (Transparent Remote [file] Access, Multiple Protocol). I am using GNU Emacs 23 trunk snapshot. TRAMP is included by default in GNU Emacs 22+. Configuration of TRAMP was quite simple. I had to load the module and set the protocol for remote access. Just a two liner in my .emacs did the trick.

(require 'tramp)
(add-to-list 'tramp-default-method-alist '("praveen.kumar.net.in" "" "ssh"))

The three entries for tramp-default-method-alist element are host, user and protocol. You can fill in the host, the user or both. Another interesting use of TRAMP is editing files as root on local machine. This can be quite handy as well. Take a look at TRAMP user guide for full configuration options. Once I added these lines, I was able to open /home/praveen/.bashrc on my server using the file name as /praveen.kumar.net.in:~/.bashrc in the normal find-file (C-x C-f) function. Happy remote editing!

2 Comments »

  1. 9 years?! Its probably less than 8 years since you got to know about Emacs et al, right? ;)

    Comment by Suraj — June 9, 2008 @ 9:38 pm

  2. I guess I first saw Emacs first at the end of 1999 (while installing Debian given by MKS). However I was not a serious user for the next 3 years, I would say!

    Comment by Praveen Kumar — June 9, 2008 @ 11:32 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress