Hi All,
I am creating snippets and I was wondering if there is a way to force tabs to follow similar lines...
Sample
Snippet 1
mytext -> -> -> Text
Snippet 2
(listens to line above and uses the tabs necessary to align Text in next line
mytexttwo -> -> Text
So it would look like this:
mytext -> -> -> Text mytexttwo -> -> Text
I can create two different snippets that use 1 or 2 or 3 tabs as neccesary but since i will never know what mytext will be I need to create the tabs in some kind of dynamic way.
Any ideas?
You could maybe achieve this with some clever format strings, but it's going to be easier (and clearer) to just do it with a command instead.
On 1 Jun 2007, at 16:21, Helmut Granda wrote:
Hi All,
I am creating snippets and I was wondering if there is a way to force tabs to follow similar lines...
Sample
Snippet 1
mytext -> -> -> Text
Snippet 2
(listens to line above and uses the tabs necessary to align Text in next line
mytexttwo -> -> Text
So it would look like this:
mytext -> -> -> Text mytexttwo -> -> Text
I can create two different snippets that use 1 or 2 or 3 tabs as neccesary but since i will never know what mytext will be I need to create the tabs in some kind of dynamic way.
Any ideas?
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
hummm... thanks for the recommendation, I'll try to figure out how to do it with a command.
Thanks!
On 6/1/07, Ciarán Walsh ciawal@gmail.com wrote:
You could maybe achieve this with some clever format strings, but it's going to be easier (and clearer) to just do it with a command instead.
On 1 Jun 2007, at 16:21, Helmut Granda wrote:
Hi All,
I am creating snippets and I was wondering if there is a way to force tabs to follow similar lines...
Sample
Snippet 1
mytext -> -> -> Text
Snippet 2
(listens to line above and uses the tabs necessary to align Text in next line
mytexttwo -> -> Text
So it would look like this:
mytext -> -> -> Text mytexttwo -> -> Text
I can create two different snippets that use 1 or 2 or 3 tabs as neccesary but since i will never know what mytext will be I need to create the tabs in some kind of dynamic way.
Any ideas?
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 1. Jun 2007, at 18:11, Helmut Granda wrote:
hummm... thanks for the recommendation, I'll try to figure out how to do it with a command.
A simple one would be:
unexpand -t $TM_TAB_SIZE <<'SNIPPET' «your snippet» SNIPPET
In «your snippet» you would use spaces instead of tabs and only start columns at offsets dividable by 24, that would then convert properly to tab sizes 2, 3, 4, 6, 8, 12, and 24.
Wow, this really doesnt make sense to me... time to hit the docs.
Thanks!
On 6/1/07, Allan Odgaard throw-away-1@macromates.com wrote:
On 1. Jun 2007, at 18:11, Helmut Granda wrote:
hummm... thanks for the recommendation, I'll try to figure out how to do it with a command.
A simple one would be:
unexpand -t $TM_TAB_SIZE <<'SNIPPET' «your snippet» SNIPPET
In «your snippet» you would use spaces instead of tabs and only start columns at offsets dividable by 24, that would then convert properly to tab sizes 2, 3, 4, 6, 8, 12, and 24.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Out of curiosity, is it possible to move text to a certain column? I noticed that I can get the information for the column where the caret is located at, but not sure if we can send text to a certain column...
On 6/1/07, Helmut Granda contact@helmutgranda.com wrote:
Wow, this really doesnt make sense to me... time to hit the docs.
Thanks!
On 6/1/07, Allan Odgaard < throw-away-1@macromates.com> wrote:
On 1. Jun 2007, at 18:11, Helmut Granda wrote:
hummm... thanks for the recommendation, I'll try to figure out how to do it with a command.
A simple one would be:
unexpand -t $TM_TAB_SIZE <<'SNIPPET' «your snippet» SNIPPET
In «your snippet» you would use spaces instead of tabs and only start columns at offsets dividable by 24, that would then convert properly to tab sizes 2, 3, 4, 6, 8, 12, and 24.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
BTW that reminds me:
Pasting code with auto-indent enabled looses all tabs on otherwise empty lines. That is quite annoying.
Gerd
On 1. Jun 2007, at 19:30, Helmut Granda wrote:
Out of curiosity, is it possible to move text to a certain column? I noticed that I can get the information for the column where the caret is located at, but not sure if we can send text to a certain column...
Not sure what exactly you want to do here, what does “move text to a certain column” imply?
for example is it possible to write a snippet to do something like...
text (move to column 100)moreText
does that makes sense? sort of tabbing but using column numbers instead (margins?)
On 6/1/07, Allan Odgaard throw-away-1@macromates.com wrote:
On 1. Jun 2007, at 19:30, Helmut Granda wrote:
Out of curiosity, is it possible to move text to a certain column? I noticed that I can get the information for the column where the caret is located at, but not sure if we can send text to a certain column...
Not sure what exactly you want to do here, what does "move text to a certain column" imply?
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 2. Jun 2007, at 06:54, Helmut Granda wrote:
for example is it possible to write a snippet to do something like...
text (move to column 100)moreText
does that makes sense? sort of tabbing but using column numbers instead (margins?)
Other than actually inserting the required number of spaces, no, there is no such shortcut.
Allan Odgaard <throw-away-1@...> writes:
On 2. Jun 2007, at 06:54, Helmut Granda wrote:
for example is it possible to write a snippet to do something like...
text (move to column 100)moreText
does that makes sense? sort of tabbing but using column numbers instead (margins?)
Other than actually inserting the required number of spaces, no, there is no such shortcut.
If the text to be inserted is always the same, you can record a macro which inserts some text, moves to the right (press right arrow 100 times) then inserts some more text...
I think this could probably be accomplished with a simple python (or ruby) script that took the line as input, then did print "%-100s" % thetext or something like that and replaced the line? (or place it in a macro that first selects the line, and the command replaces the selection...)
As for the original question, woulnd't it be failry straight forward to have something like:
sometext⇥more text somemoretext⇥and a bit more whateverelse⇥some more
then opt-shift-up, and parse the selection through a small python script that splits each line on the tab character, finds the longest first half of a line, and aligns everything using spaces...
in fact, this seems to work as a command (takes the first tab it finds in every line, and adds enough spaces before it so that all the first tabs in each line align):
Command Input: Selected Text or Nothing Output: Replace Selected Text Activation: Key Equivalent (i set it to cmd-opt-shift-r) Command:
#!/usr/bin/env python import os
selectedText = '' splitMarker = "\t" joinMarker = "\t"
if 'TM_SELECTED_TEXT' in os.environ: selectedText = os.environ['TM_SELECTED_TEXT'] lines = selectedText.splitlines() length = 0 for i in range(len(lines)): sec = lines[i].split(splitMarker) length = max(length, len(sec[0])) l = "%%-%ds" % length for j in range(len(lines)): sec = lines[j].split(splitMarker) sec[0] = l % sec[0] print joinMarker.join(sec)
This is very rough, i wrote it while writing this email, but it seems to work. Using it in the above proposed method also seems to work (i.e. write all the data in a column block, have the first tab where you want everything to align, opt-shift-up, opt-cmd-shift-R)
Note instead of the first tab, the align 'marker' can be anything...
On Jun 2, 2007, at 12:38 PM, Piero D''Ancona wrote:
Allan Odgaard <throw-away-1@...> writes:
On 2. Jun 2007, at 06:54, Helmut Granda wrote:
for example is it possible to write a snippet to do something like...
text (move to column 100)moreText
does that makes sense? sort of tabbing but using column numbers instead (margins?)
Other than actually inserting the required number of spaces, no, there is no such shortcut.
If the text to be inserted is always the same, you can record a macro which inserts some text, moves to the right (press right arrow 100 times) then inserts some more text...
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Constantinos,
Thanks for the script, at first test it doesnt work but I'll dig into it to figure out a way to make it work.
Thanks again....
On 6/2/07, Constantinos Neophytou ♎ jaguarcy@gmail.com wrote:
I think this could probably be accomplished with a simple python (or ruby) script that took the line as input, then did print "%-100s" % thetext or something like that and replaced the line? (or place it in a macro that first selects the line, and the command replaces the selection...)
As for the original question, woulnd't it be failry straight forward to have something like:
sometext⇥more text somemoretext⇥and a bit more whateverelse⇥some more
then opt-shift-up, and parse the selection through a small python script that splits each line on the tab character, finds the longest first half of a line, and aligns everything using spaces...
in fact, this seems to work as a command (takes the first tab it finds in every line, and adds enough spaces before it so that all the first tabs in each line align):
Command Input: Selected Text or Nothing Output: Replace Selected Text Activation: Key Equivalent (i set it to cmd-opt-shift-r) Command:
#!/usr/bin/env python import os
selectedText = '' splitMarker = "\t" joinMarker = "\t"
if 'TM_SELECTED_TEXT' in os.environ: selectedText = os.environ['TM_SELECTED_TEXT'] lines = selectedText.splitlines() length = 0 for i in range(len(lines)): sec = lines[i].split(splitMarker) length = max(length, len(sec[0])) l = "%%-%ds" % length for j in range(len(lines)): sec = lines[j].split(splitMarker) sec[0] = l % sec[0] print joinMarker.join(sec)
This is very rough, i wrote it while writing this email, but it seems to work. Using it in the above proposed method also seems to work (i.e. write all the data in a column block, have the first tab where you want everything to align, opt-shift-up, opt-cmd-shift-R)
Note instead of the first tab, the align 'marker' can be anything...
On Jun 2, 2007, at 12:38 PM, Piero D''Ancona wrote:
Allan Odgaard <throw-away-1@...> writes:
On 2. Jun 2007, at 06:54, Helmut Granda wrote:
for example is it possible to write a snippet to do something like...
text (move to column 100)moreText
does that makes sense? sort of tabbing but using column numbers instead (margins?)
Other than actually inserting the required number of spaces, no, there is no such shortcut.
If the text to be inserted is always the same, you can record a macro which inserts some text, moves to the right (press right arrow 100 times) then inserts some more text...
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
-- What's your Dream? Make it happen with www.dostpost.com
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate