Hi, I'm new to TextMate, coming from Vim.
Is there an equivalent to Vim's textwidth setting, which automatically wraps a line as you type past the nth character? The new line is indented two extra tab stops generally.
If not, is this something which would be possible with a plug-in (when the API is ready)?
Thanks,
Ben
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
Hey Ben,
If you go to the View menu, there is a menu-item for Soft-Wrapping text, and another menu-item Wrap Column for picking where wrapping should begin. This doesn't indent the text over though. (If you are talking about hard line breaks then I'm not sure how that is done.)
Ramanan
On 23-Mar-06, at 11:11 PM, Afternoon wrote:
Hi, I'm new to TextMate, coming from Vim.
Is there an equivalent to Vim's textwidth setting, which automatically wraps a line as you type past the nth character? The new line is indented two extra tab stops generally.
If not, is this something which would be possible with a plug-in (when the API is ready)?
Thanks,
Ben
We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
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 24 Mar 2006, at 4:16, Ramanan Sivaranjan wrote:
If you go to the View menu, there is a menu-item for Soft-Wrapping text, and another menu-item Wrap Column for picking where wrapping should begin. This doesn't indent the text over though. (If you are talking about hard line breaks then I'm not sure how that is done.)
Thanks Ramanan. I am looking for hard breaks to be inserted into the document and for indentation to be adjusted. Ideally, it would be good to have line continuation characters inserted in scopes that need it, e.g. Python, as well.
Ben
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
I'm curious : what's the point of hard-wrapping ? I've never understood in which cases it's useful. Please enlighten me.
2006/3/24, Afternoon afternoon@uk2.net:
On 24 Mar 2006, at 4:16, Ramanan Sivaranjan wrote:
If you go to the View menu, there is a menu-item for Soft-Wrapping text, and another menu-item Wrap Column for picking where wrapping should begin. This doesn't indent the text over though. (If you are talking about hard line breaks then I'm not sure how that is done.)
Thanks Ramanan. I am looking for hard breaks to be inserted into the document and for indentation to be adjusted. Ideally, it would be good to have line continuation characters inserted in scopes that need it, e.g. Python, as well.
Ben
We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
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
I always like to keep the length of lines down under 80 chars. I rarely edit in a window much wider that that, and even if I did it gets very hard for the eye to scan from end of line to the beginning of the next over 12-14 words. For example, when writing HTML, paragraphs are more easily read if they're not on one strapping great line and if indentation is correct. I'm aware of the Reformat Paragraph command, but this doesn't take structure or context into account. When writing code, long lines get complicated, perhaps they could be refactored to be simpler. As I'm a bit of a nerd, I appreciate the editor pointing out when I've exceeded the threshold and help me to refactor.
Basically, it's a style thing.
On 24 Mar 2006, at 4:57, Ned Baldessin wrote:
I'm curious : what's the point of hard-wrapping ? I've never understood in which cases it's useful. Please enlighten me.
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
On Mar 23, 2006, at 11:12 PM, Afternoon wrote:
I always like to keep the length of lines down under 80 chars. I rarely edit in a window much wider that that, and even if I did it gets very hard for the eye to scan from end of line to the beginning of the next over 12-14 words. For example, when writing HTML, paragraphs are more easily read if they're not on one strapping great line and if indentation is correct. I'm aware of the Reformat Paragraph command, but this doesn't take structure or context into account. When writing code, long lines get complicated, perhaps they could be refactored to be simpler. As I'm a bit of a nerd, I appreciate the editor pointing out when I've exceeded the threshold and help me to refactor.
Well, with soft-wraps, the editor in a way *will* tell you that you've exceeded the threshold, when it moves the pointer to the very left end of the next line. :) Alternatively, you can do the following, highly not recommended for a number of reasons but nonetheless amusing "hack": You can create, in each language in which you want the feature, a scope, called maybe meta.toolong.yourlanguage, or even better meta.illegal.toolong.yourlanguage and set its regexp to detect a sequence of 78 characters with no newlines. Using the word illegal there would color it as illegal syntax, so that it quite an indicator I would say. You could if you prefer create this scope in a new language, called maybe source.general, and include it in any other language you want. For extra credit, (even more hideous hack), you can create, for each character, a snippet, with scope meta.illegal.toolong, which would insert whatever you want it to insert. Or, what is more reasonable, just bind return to one snippet that inserts the appropriate thing. You can even have this snippet as a command and have it common for all languages, and have it detect which language it is using through the TM_SCOPE variable, and accordingly insert the appropriate continuation character etc.
All this is quite far from ideal of course, for a number of reasons. Once Allan implements dynamic scopes maybe there will be a more elegant solution.
Haris
I haven't found a setting for it :-). It automatically inserts appropriate comment characters and indentation on the next line, so adding a line continuation character should be within it's capabilities (it's detecting scope etc so it would be able to tell if it's inside a string etc). High chance that it's feasible in script.
On 24 Mar 2006, at 5:10, Trevor Harmon wrote:
That would be very cool. Can Vim do that already?
Trevor
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
In the menu "View" there is "Wrap column" and then in Preferences you can make TextMate highlight your "margin", and that would give you a clear visual of how long your lines is.
It's not exactly what you're asking for, but it could help you make more aware.
/David
On 24/03/2006, at 5.11, Afternoon wrote:
Hi, I'm new to TextMate, coming from Vim.
Is there an equivalent to Vim's textwidth setting, which automatically wraps a line as you type past the nth character? The new line is indented two extra tab stops generally.
If not, is this something which would be possible with a plug-in (when the API is ready)?
Thanks,
Ben
We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
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
Thanks David, that's quite handy.
I guess this is going to be a plugin thing. Better brush up my Objective C in time...
On 24 Mar 2006, at 9:23, David Pedersen wrote:
In the menu "View" there is "Wrap column" and then in Preferences you can make TextMate highlight your "margin", and that would give you a clear visual of how long your lines is.
It's not exactly what you're asking for, but it could help you make more aware.
/David
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
On 24/3/2006, at 15:49, Afternoon wrote:
Thanks David, that's quite handy.
I guess this is going to be a plugin thing. Better brush up my Objective C in time...
Currently it’s not really possible to do as a plug-in.
What you could do was create a command, let that command do something like:
if [[ $TM_COLUMN_NUMBER -gt 78 ]] then echo -ne '\n\t\t' else echo -ne ' ' fi
Then set the key equivalent of this command to space, set the input to “none” and output to “insert as snippet”.
Then when you press space, and you are at a column position higher than 78, it will insert a newline and two tabs.
You can even customize this command for different scopes using the scope selector, e.g. in comments you can have it also insert the comment character on the new line, and similar for strings.
Great, thanks. That works and I think I can find my way to customising it, writing commands to join lines back together after editing and such.
What's the performance impact here, does TextMate create a new instance of sh every time I hit space?
The ideal case for me, and this would be surpassing raw Vim (as in without a script) here, would be that TextMate could detect "linked" lines in scopes and reflow them dynamically, so deleting characters from a long line would allow words from the surrogate lines to return to the first line, and typing characters on an intermediate line would reflow the block. Am I right in thinking this would be impossible to do transparently in a command because it's not possible to infer the block that needs to be reflowed? Once the block was identified you could just pass it to a script relatively easily.
On 24 Mar 2006, at 15:02, Allan Odgaard wrote:
if [[ $TM_COLUMN_NUMBER -gt 78 ]] then echo -ne '\n\t\t' else echo -ne ' ' fi
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/
I use the esc completion key all the time but the escape key on the powerbook is small and I often end up hitting the key to the left of 1 (§). My frustration level eventually was eclipsed so I made a macro just holding nextCompletion command and assigned it to the offending key.
Works a treat so now even when I miss the escape I get what I want.
Dave.
On 24/3/2006, at 16:30, Afternoon wrote:
What's the performance impact here, does TextMate create a new instance of sh every time I hit space?
Yes. I have considered keeping an interpreter per document, also to be able to re-use variables and have the ctrl-R feature closer to a real shell (i.e. with state) -- but it won’t happen before I revamp the command infrastructure.
The ideal case for me, and this would be surpassing raw Vim (as in without a script) here, would be that TextMate could detect "linked" lines in scopes and reflow them dynamically, so deleting characters from a long line would allow words from the surrogate lines to return to the first line, and typing characters on an intermediate line would reflow the block.
So exactly like soft wrap, but with the “on disk” representation having the returns ;)
Am I right in thinking this would be impossible to do transparently in a command because it's not possible to infer the block that needs to be reflowed? [...]
Yes -- currently a command can only get the current word, line, selection or document as input. Not paragraph (or custom regexp defined portion).
On 26 Mar 2006, at 9:57, Allan Odgaard wrote:
So exactly like soft wrap, but with the “on disk” representation having the returns ;)
Yes, except correctly indented as well.
A more general system would be to allow control of wrap indentation:
[ ] Indent soft wrapped lines to match parent Add n tabs to soft wrapped lines [ 2 ] [ ] Don't soft wrap, hard wrap
This would cover my style and Oliver Taylor's too, I think (apologies if I haven't understood).
From an implementation point of view, the soft wrapping version implicitly knows about the blocks, they're still lines, it's just drawing them differently. With hard wraps, the only suggestion I have is a crappy one, infer the blocks from knowledge about how the user likes the wrapping done. E.g. if I say indent subsequent lines by 2 tabs then everything 2 tabs from the line above in is a child. This only works if the indentation is 2 tabs or greater though, because 0 tabs, 1 tab and negative values would result in the entire document becoming a false positive in most cases.
Hmm.
________________________________ We're cycling through Cambodia to raise money for Oxfam, help us raise £5,200! http://cambodiachallenge.org/