Sublime Forum

Mimicking TextMate's auto-insert of {} on #?

#1

I like that TextMate, when in the appropriate Ruby string scope, will take # as a trigger to insert {} and put my cursor in the middle. Where would I start to look in Sublime to do this? The auto_match characters seem hardcoded.

0 Likes

#2

Add this to your user keybinding config

  {
    "args": {
      "contents": "#{${0:$SELECTION}}"
    }, 
    "command": "insert_snippet", 
    "context": 
      {
        "key": "selector", 
        "match_all": true, 
        "operand": "string.quoted.double.ruby", 
        "operator": "equal"
      }
    ], 
    "keys": 
      "#"
    ]
  },

i don’t recall exactly where this came from. either somewhere on this forum or on the nets.

0 Likes