I'm trying to maximize my use of textmate. One of the first things I'm doing is looking through the ruby bundle to see what snippets I can use. I first noticed the hash key/val snippet, which starts with a colon.
The first thing it does is highlight the key so that I can type in a new key.
The next thing it does is highlight the sample string so that I can type in something different. However, I'm having trouble typing something in at this point. If I want to edit the string inside, is there a key I can type that will put the caret inside the quotes? If want to edit the string contents, I have to move my cursor over then back. If I start typing, it erases the quotes. If I type quotes, it surrounds the quotes in another set of quotes. Is this behavior there because the snippet writer assumed I would not always want to put strings in the hash buckets? This is understandable, but as a shortcut for creating symbol/string combinations it is actually quite tedious.
I figured maybe I was missing some secret keyboard shortcut that would put me inside a fresh set of empty quotes instead of the sample that is highlighted.
Thanks, Carl
On 1/2/2006, at 20:27, Carl Youngblood wrote:
The next thing it does is highlight the sample string so that I can type in something different. However, I'm having trouble typing something in at this point. If I want to edit the string inside, is there a key I can type that will put the caret inside the quotes? [...]
There is not, but the snippet can be changed e.g. to:
:${1:key} => ${2:"${3:value}"}${4:, }
That way, it would just be pressing tab (again) to get “inside” the quotes. If you mainly do use it for strings, it might be more efficient to swap the two placeholders:
:${1:key} => ${3:"${2:value}"}${4:, }
That way it goes first to the value, and on second tab, the quotes.
This snippet is one of the first snippets created for TM, so this ability did not exist at the time of creation -- it would make sense to update the default snippet to the first version shown here (so I'll likely do that).