I have a number of Commands to insert some text into the document, but all of them have a couple of 'side-effects' that I don't want.
1. The inserted text is always selected, and I would prefer it to not be selected.
2. There is always a New line character behind the input, whereas I would just want the cursor to remain immediately behind the inserted text on the same line.
What is it that I'm missing or doing wrong ?? Any help would be gratefully received.
Command Examples:
INSERT DATE: Save: Nothing Command: echo `date +%Y-%m-%d` Input: None Output: Tried all versions ( Insert as Snippet / Replace Selected text / etc )
INSERT PATH2FILE: Save: Nothing Command: echo $TM_FILEPATH | sed "s|^$TM_USER_ROOT_DIRECTORY(.*)$|\1|" Input: None Output: Tried all versions ( Insert as Snippet / Replace Selected text / etc )
Kind regards,
Mats
---- "TextMate, coding with an incredible sense of joy and ease" - www.macromates.com -
On 11 Feb 2005, at 12:47, Mats Persson wrote:
- There is always a New line character behind the input, whereas I
would just want the cursor to remain immediately behind the inserted text on the same line.
You can use the -n switch to remove the trailing newline, i.e.
echo -n `date +%Y-%m-%d`
hth,
Rich Barton
On 11 Feb 2005, at 11:57, Rich Barton wrote:
On 11 Feb 2005, at 12:47, Mats Persson wrote:
- There is always a New line character behind the input, whereas I
would just want the cursor to remain immediately behind the inserted text on the same line.
You can use the -n switch to remove the trailing newline, i.e. echo -n `date +%Y-%m-%d`
Thanks Rich, that helped me a lot. Now I can just 'arrow-left' and continue typing. Thank you!
Kind regards,
Mats
---- "TextMate, coding with an incredible sense of joy and ease" - www.macromates.com -
On 11 Feb 2005, at 12:06, Mats Persson wrote:
On 11 Feb 2005, at 11:57, Rich Barton wrote:
On 11 Feb 2005, at 12:47, Mats Persson wrote:
- There is always a New line character behind the input, whereas I
would just want the cursor to remain immediately behind the inserted text on the same line.
You can use the -n switch to remove the trailing newline, i.e. echo -n `date +%Y-%m-%d`
Thanks Rich, that helped me a lot. Now I can just 'arrow-left' and continue typing. Thank you!
Ah, spoke to early there. :( The following command still produces a New line character behind it.
echo -n $TM_FILEPATH | sed "s|^$TM_USER_ROOT_DIRECTORY(.*)$|\1|"
Any idea of how to avoid that one ???
Kind regards,
Mats
---- "TextMate, coding with an incredible sense of joy and ease" - www.macromates.com -
On Feb 11, 2005, at 7:13 AM, Mats Persson wrote:
Ah, spoke to early there. :( The following command still produces a New line character behind it.
echo -n $TM_FILEPATH | sed "s|^$TM_USER_ROOT_DIRECTORY(.*)$|\1|"
Any idea of how to avoid that one ???
echo $TM_FILEPATH | sed "s|^$TM_USER_ROOT_DIRECTORY(.*)$|\1|" | tr -d '\n'
On 11 Feb 2005, at 12:32, Brian Lalor wrote:
On Feb 11, 2005, at 7:13 AM, Mats Persson wrote:
Ah, spoke to early there. :( The following command still produces a New line character behind it. echo -n $TM_FILEPATH | sed "s|^$TM_USER_ROOT_DIRECTORY(.*)$|\1|" Any idea of how to avoid that one ???
echo $TM_FILEPATH | sed "s|^$TM_USER_ROOT_DIRECTORY(.*)$|\1|" | tr -d '\n'
Thank you Brian !! I've been trying to read and understand all this *NIX stuff, but can't seem to get it. Will keep on trying though.
Kind regards,
Mats
---- "TextMate, coding with an incredible sense of joy and ease" - www.macromates.com -
On Feb 11, 2005, at 12:47, Mats Persson wrote:
- The inserted text is always selected, and I would prefer it to not
be selected.
You should be able to not have it selected if you insert as snippet.
- There is always a New line character behind the input, whereas I
would just want the cursor to remain immediately behind the inserted text on the same line.
I know this was already answered, but just to summarize:
echo -n <your text> # insert text w/o newline echo <your text> | tr -d '\n' # let tr delete any newline characters
Additionally you can also create your “command” as a snippet. Snippets lets you execute shell commands using backticks (`) so e.g. this snippet:
`date +%Y-%m-%d`
Would insert current date. For shell commands in snippets, TextMate automatically removes the last newline. And actually, if you look in the Text Utilities bundle, there already is a snippet to insert current date, though with time zone set to GMT [1] and including hours/minutes/seconds. The tab trigger is 'isoD'.
[1] after having worked with date-stamped information, I have given up on local time-zones and their DST oddities ;)
On Feb 11, 2005, at 21:28, Sune Foldager wrote:
[...] with time zone set to GMT [...]
I believe using UTC would be more "correct", since GMT is a zone, and UTC is a different time standard ;)... but this is nit-picking of course, since they of course coincide.
Since the actual snippet is:
`TZ=GMT date +%Y-%m-%dT%H:%M:%SZ`
It quite literally sets the time zone (TZ) to GMT! :)
But I see that TZ=UTC actually also works -- quite sure I discarded that as non-working when I did the snippet. Must have been the latest 10.3.8 update ;)