[TxMt] Re: snippet that replaces the current word
Hans-Jörg Bibiko
bibiko at eva.mpg.de
Tue Sep 23 06:25:53 UTC 2008
On 23.09.2008, at 00:34, Timothy Bates wrote:
> I'm trying to write a snippet for wikimedia for applying bold
> (wrapping a string in **str**)
>
> I've attached cmd-B to the snippet, and I'd like it to bold the
> CURRENT_WORD if there is no selection.
> Sounds like a job for:
>
> **${TM_SELECTED_TEXT:$TM_CURRENT_WORD}**
>
> Works fine for the selected text, but not for the current word, where
> it returns things like this:
>
> he|re -->cmd-B--> he**here**re
>
> Any pointers, or do I need to be made into a command? (in that case,
> what use does $TM_CURRENT_WORD have in snippets?
TM's snippet system 'only' inserts something. It only replaces
something if you invoke it via 'foo' and pressing TAB.
Ad hoc I do not know whether one needs $TM_CURRENT_WORD in a snippet
but one never knows.
In a snippet one could write **${1:${TM_SELECTED_TEXT:text}}**
Or even a command à la:
input: selection or word
echo -n "**`cat`**"
output: replace selection
if you don't select something in beforehand.
--Hans
More information about the textmate
mailing list