Hi.
I'm new to textmate (although I did at least buy a license for it), and have one of those questions that probably comes up a lot. In my defense, I did first skim through the beta-book from Pragmatic Programmers on "Power Editting" with TextMate, and I did try a number of searches on both the wiki and some of the mailing lists archives. I haven't found any mention of what I wanted to find, but maybe I just wasn't picking the right search terms. So, apologies if this is one of those hot-button topics which people are tired of hearing of...
In any case, what I want to have is a combination of hard tabs and soft tabs, and I can't see how to get what I want out of TextMate. What I want is my tab-intent to be a soft-tab (using blanks) at 4 spaces, but I also want hard-tabs (using the actual tab character) to be used for 8 spaces. So, if I tab once I want four spaces, if I tab twice then I want a single tab character, and with three tabs I want a tab-character followed by four spaces. I can get this behavior out of XCode, and it would be very very useful to me if I could get the same behavior out of TextMate.
In XCode, I get this behavior via the "Indentation" preferences, by turning on "Tab key inserts tab, not spaces", and setting tab width=8 and indent width=4. Apologies if I'm missing some obvious setting in TextMate.
Thanks for any suggestions. Other than this one oddity, TextMate looks like it could be very useful and productive for me -- once I can master all that it can do! :-)
On Jan 31, 2007, at 12:50 AM, Garance A Drosehn wrote:
What I want is my tab-intent to be a soft-tab (using blanks) at 4 spaces, but I also want hard-tabs (using the actual tab character) to be used for 8 spaces. So, if I tab once I want four spaces, if I tab twice then I want a single tab character, and with three tabs I want a tab-character followed by four spaces.
Someone will correct me if I'm wrong, but I don't think you can have TextMate do this for you just by altering settings.
You could probably create a command that goes through your document and replaces 8 spaces with a tab character. To get even fancier, you could probably create a command that does this and saves the document and bind this command to ⌘S, so when you save the file, it gets formatted the way you want.
I'm not sure if TextMate will let you use Tab as a key equivalent for a command, but if so, you could make it even more automated (probably what you want) by having it do a search/replace on the current line every time you hit the Tab key. This might screw up the cursor position though.
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
On Jan 31, 2007, at 9:51 AM, Rob McBroom wrote:
On Jan 31, 2007, at 12:50 AM, Garance A Drosehn wrote:
What I want is my tab-intent to be a soft-tab (using blanks) at 4 spaces, but I also want hard-tabs (using the actual tab character) to be used for 8 spaces. So, if I tab once I want four spaces, if I tab twice then I want a single tab character, and with three tabs I want a tab-character followed by four spaces.
Someone will correct me if I'm wrong, but I don't think you can have TextMate do this for you just by altering settings.
You could probably create a command that goes through your document and replaces 8 spaces with a tab character. To get even fancier, you could probably create a command that does this and saves the document and bind this command to ⌘S, so when you save the file, it gets formatted the way you want.
I'm not sure if TextMate will let you use Tab as a key equivalent for a command, but if so, you could make it even more automated (probably what you want) by having it do a search/replace on the current line every time you hit the Tab key. This might screw up the cursor position though.
Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
Ya. It's Tabs or spaces. no mixing. Don't bother trying to write a tmCommand for this since you'd break snippet placer stuff and open up a whole can of trouble and pain for yourself. I recommend using tabs at 4 and just using two of them in some places.
If you already have documents that assume 4spaces + 8wide tabs, you can switch to using all tbs by setting it to use 8wide soft tabs (spaces), use the convert tabs to spaces action o convert all your 8 wide tabs to 8spaces, then switch to hard tabs at 4width and convert spaces to tabs.
thomas Aylott — design42 — subtleGradient — CrazyEgg
On Jan 31, 2007, at 9:51 AM, Rob McBroom wrote:
Someone will correct me if I'm wrong, but I don't think you can have TextMate do this for you just by altering settings.
Correct, it will not.
You could probably create a command that goes through your document and replaces 8 spaces with a tab character. To get even fancier, you could probably create a command that does this and saves the document and bind this command to ⌘S, so when you save the file, it gets formatted the way you want.
That is definitely possible. Perhaps there are already some solutions in the list archives, this kind of thing has come up before.
I'm not sure if TextMate will let you use Tab as a key equivalent for a command, but if so, you could make it even more automated (probably what you want) by having it do a search/replace on the current line every time you hit the Tab key. This might screw up the cursor position though.
Tab is the key associated to tab triggers. So you could use it as a key equivalent, but that would disable all key triggers.
Actually what would probably work is setting tab as a "tab trigger". Then the command will only be triggered if it is preceded by a tab (and will swallow that tab).
Haris
On Jan 31, 2007, at 10:15 AM, Charilaos Skiadas wrote:
Actually what would probably work is setting tab as a "tab trigger". Then the command will only be triggered if it is preceded by a tab (and will swallow that tab).
Ok, here are some more details on it. I've actually attached the two commands that would do this, so you can use those as they are, or you can reproduce them as follows. Set the tab setting to soft tabs: 4. Create a new command, with tab trigger set to four spaces, and with command text:
echo -n " "
So that's echo -n followed by a tab in quotes. Set the input to none, and the output to Insert As Text.
Create a second command, with tab trigger a tab character (you would need to copy and paste the character in there to get it there), input none and output insert as text, and with command text:
echo -n " "
So in the quotes there are now a tab followed by four spaces.
This should give you the desired behavior without compromising the tab triggers. Just make sure you set the above two commands to use a tab trigger, not a key equivalent.
Haris
Haris
* Charilaos Skiadas skiadas@hanover.edu [2007-01-31 10:10]:
echo -n " "
So that's echo -n followed by a tab in quotes.
You can make this more obvious with: echo -ne "\t"
That works with Bash's built-in echo, but not with /bin/echo.