When creating a file in emacs C-x C-f and typing in a filename (for example, abc.rb) the Ruby mode is activated. In this mode, there is one nice feature that has been included (Might be in others as well. I am still a noob.) is automatic tab indentations. Here is an example:

  1. Type the beginning of the file "Class Animal"
  2. Insert 2 returns
  3. At this point hitting tab will not do anything
  4. Type "def name"
  5. hit enter
  6. Now hit tab once and you should notice that it indents 2 space characters

After playing with this a couple of minutes, I also noticed a better way to code. I no longer have to hit tab to start programming! I just start to program my line, and hit tab at the end, and emacs takes care of the rest. I shall illustrate below:

  1. While inside a "def" block
  2. without hitting tab, type a line of text, and do not hit enter when you are done
  3. hit the tab button
  4. you should notice your code line will be indented where it needs to be

The tab button only needs to be hit once to align correctly. I have to guess that this is not completely perfect as most things like this feature have some flaw, but for now, I am a happy EMacs camper. I am sure that automatic tabbing is not limited to only the Ruby mode. But its the first file type that arrives in my mind when testing out stuff because I am a rubyist at heart.

comments powered by Disqus