Sensible Open Source

Textmate Comment Shortkeys!

posted 20 November 2009, Friday

I've been using Textmate, for as long as I can remember.  However, comment blocking, toggling on and off etc is so embedded in my "TEXTMATE" typing I catch myself attempting to use it in others editors all the time.  Its become second nature to me.

When asked, today, how to toggle on and off comments in Textmate like Dreamweaver this morning, I guess my expression seemed to be not very PC... What I was thinking is why can't I just say it!!  I was shocked at myself, disappointed I guess, alas, I needed a keyboard.  The poor chap that asked took my look as a punch on his ego! Which was certainly not my intention, not for a second.  I apologized to him immediately on recognizing his expression was not very pleasing!! And, of course, I apologized to myself to myself.   I wouldn't treat anyone with anger over something so trivial, but here I was beating myself up and caught by a colleague! He was right to be put out by the internal beating I was giving myself.  We straightened it as quick as the misunderstanding occurred! its important to always treat others well, and that includes yourself!!  

Well, it just stops here and as matter of sharing the wealth and no further ado the short keys for comments:

MAC OSX KEYS 

  1. COMMAND + "/" Toggle Comments 
    • Example HTML
    •  <!-- <img src="ad_space" alt="ad space"> -->

  2. Alt+COMMAND+"/" Comments block or subset of a line // 
    • Example Ruby
       
              <!--<%= render_this unless %w(admin).include?(params[:controller]) %>-->
       
       OR end of line

      <div id="tab_content"><!--
      -->
       
  3. Type "head"+TAB Inserts Comment Header at top of file //  
    • Example Java
       
      // «file» 
       // «project» 
       // 
       // Created by jes on 2009-11-20. 
       // Copyright 2009 AIT, Inc. All rights reserved. 
       //

  4. Control+Shift+B Inserts Comment Banner (Declarations, Functions, Modules, etc) // 
    • Example YAML
      # =======================
      # = defaults: &defaults
        adapter: mysql
        database: mydb
        username: myuid
        host: localhost = mypasswd
      # =======================

  5. Type "todo" + TAB
    • Example Ruby
    •  
        =begin
          TODO 
        =end

    • Example Java
    •  
        /*
        TODO 
        */

    Saves alot of time!!


tags:        

links: digg this    del.icio.us    technorati    reddit