Archive

Posts Tagged ‘editors’

Emacs – Smarter way of switching buffers in Emacs.

August 4, 2009 Leave a comment

Add (iswitchb-mode t) to your .emacs file and see magic happen (you have to re-load the .emacs file) or you could type M-X <enter> iswitchb-mode in the emacs window directly. Once you enable this mode, C-X b will allow you to narrow down to a buffer by typing any part of the buffer name. If there is more than one partial match, you can rotate between the default selections by C-S C-R. Keep C-Ring till the buffer of your choice is at the start.This is so much better than the default behavior of C-X b where you have to start typing from the start – the buffer names you are interested and use tab completions to make your life a little easier. This mode is hands-down superior. Far less typing required to jump to the buffer of your choice, wonder why it isn’t the default mode.

Categories: emacs, programming Tags: , , ,

Replace something with a newline in emacs

I did this a few times, and today I forgot how to do it. After making a  few failed attempts including Ctrl q + [Enter], I stumbled upon ex-yahoo Jeremy Jawodny’s blog post here.  For my own reference – Ctrl q + Ctrl j is how you do it.

One more cool trick I used to forget (not anymore), is the align-regexp trick in emacs.

use constant LOG_WARN => 1;
use constant LOG_DEBUG          => 2;
use constant LOG_INFO => 3;

becomes

use constant LOG_WARN       => 1;
use constant LOG_DEBUG      => 2;
use constant LOG_INFO         => 3;

on align-regexp [Enter] ‘=>’

Very neat. I remember longing for this feature in Eclipse a few years ago, I am not sure, if you can align strings based on regex’s in Eclipse editor today. Investigating this will probably be an exercise for another day.

Emacs – Working with remote files

(This posting is mostly for my reference and will be glad, if it can be useful to others)

Well, I keep oscillating between using

  • tramp to securely edit my remote files
  • emacsclient over ssh to connect to my remote emacs server

I remember, when I first started using tramp with carbon emacs on OSX – it was unable to cache passwords as password.el file was either missing or not getting loaded. I downloaded this file separately, am loading it now during emacs initialization. Password caching makes my life a lot more simpler when I am editing files at multiple remote locations

I just added the following lines in my .emacs file after downloading tramp

(setq tramp-default-user “<login name>”
tramp-default-host “<hostname>”)
(require ‘tramp)
(setq tramp-default-method “scp”)

For attaching to a remote emacs-server securely – I run the following in an xterm

ssh -X <mydesktopname>-f  ’emacsclient –eval “(make-frame-on-display \”$DISPLAY\”)”‘

I keep vacillating between both the methods, depending on my needs.

Design a site like this with WordPress.com
Get started