in other words automate the process of automatically starting a new line after 80 characters.
I am sure there must be a setting somewhere .....
Thanks, Christopher
On 20.12.2009, at 22:00, Christopher Brewster wrote:
in other words automate the process of automatically starting a new line after 80 characters.
I am sure there must be a setting somewhere .....
Hmm, I do not know whether the following could help you but maybe you play with it [Is only a fast thought idea! ;) ]
- create a tmcommand in the Bundle Editor input: none output: discard command: if [ ${#TM_CURRENT_LINE} -gt $TM_COLUMNS ]; then osascript -e 'tell app "System Events" to keystroke " "' -e 'tell app "System Events" to keystroke "q" using (control down)' -e 'tell app "System Events" to keystroke " "' else echo -en " " exit 203 fi
- bind that command e.g. to "space"
That command reformats the paragraph (^Q) if the current line length is greater than the wrap column setting (main menu > View > Wrap Column).
Cheers, --Hans
On 20 Dec 2009, at 17:06, Hans-Jörg Bibiko wrote:
On 20.12.2009, at 22:00, Christopher Brewster wrote:
in other words automate the process of automatically starting a new line after 80 characters.
I am sure there must be a setting somewhere .....
Hmm, I do not know whether the following could help you but maybe you play with it
Wow, talk about swatting a fly with a hammer! :-)
The short answer to Christopher's question is, unfortunately, "No, there's no setting for that". Hans's script would work with a little tweaking, but personally I'd hate to run a shell script every time I hit space.
I think the best solution is to turn on View -> Soft Wrap and try to remember to hit ^Q at the end of your paragraphs. Or at the end of the document, select all and hit ^Q. If you're daring you could try binding the return key to a script similar to what Hans posted. Forking a shell script once a paragraph isn't as bad as after every word.
-- Steve King Sr. Software Engineer Arbor Networks +1 734 821 1461 www.arbornetworks.comhttp://www.arbornetworks.com/
It's not clear whether the OP is looking for soft wrapping or hard wrapping. If it's just soft wrapping you're after, that's easy: turn on View->Soft Wrap (as Steve said) and set the View->Wrap Column to 80. This will wrap the lines at 80 columns no matter how wide your window is.
Be aware, though, that this will *not* put a line feed at the end of each line. Such "hard wrapping" is traditional in Unix text editors, but not in Mac editors. TextMate follows the Mac tradition and doesn't have an automatic hard wrapping setting built in. In addition to the previous suggestions, you could also create a command with
1. Save: Current File 2. Command(s): fmt -w 80 3. Input: Entire Document 4. Output: Replace Selected Text
Binding this to ⌘S will hard wrap the document to 80 columns every time you save (assuming you use ⌘S to save rather than the menu).
For what it's worth, I used hard wrapping in my Linux days, and it always screwed up the non-Linux users I shared text files with. Since moving to the Mac, I've gone with soft wrapping and never looked back.
On 21.12.2009, at 15:27, King, Steven wrote:
Wow, talk about swatting a fly with a hammer! :-)
Yes, of course ;)
But here's an other approach - a plugin.
Simply double-click at it to install.
- then restart TM and go to Main Menu > Text > … - you will see a menu item "Auto-Reformat Paragraph" - click on it for switching it on/off
The plugin listens at any changes of the current doc (the length of the text buffer) and at changes of any Wrap Column settings (including window resizing). If it was triggered a "Reformat Paragraph" will be executed delayed by 1 sec if TM is idle (meaning if no changes are made for 1sec).
Comments?
Cheers, --Hans
On 22 Dec 2009, at 19:30, Hans-Jörg Bibiko wrote:
On 21.12.2009, at 15:27, King, Steven wrote:
Wow, talk about swatting a fly with a hammer! :-)
Yes, of course ;)
But here's an other approach - a plugin.
This is what I love about the TM community. One asks a vague question and in a blink of eyelid someone has come up with a bundle.
Thank you, Happy Christmas,
Christopher
On 22/12/2009, at 7:30 PM, Hans-Jörg Bibiko wrote:
On 21.12.2009, at 15:27, King, Steven wrote:
Wow, talk about swatting a fly with a hammer! :-)
Yes, of course ;)
But here's an other approach - a plugin.
Simply double-click at it to install.
- then restart TM and go to Main Menu > Text > …
- you will see a menu item "Auto-Reformat Paragraph"
- click on it for switching it on/off
The plugin listens at any changes of the current doc (the length of the text buffer) and at changes of any Wrap Column settings (including window resizing). If it was triggered a "Reformat Paragraph" will be executed delayed by 1 sec if TM is idle (meaning if no changes are made for 1sec).
Comments?
It seems to me that the plugin has a few problems:
1) how to prevent to reformat already formatted paragraphs?
suppose you have a few short lines
xxx yyy zzz
the plugin reformats the lines above as
xxx yyy zzz.
A real TM hard-wrap option would be good (I think it was asked several times with no avail).
2) it seems it introduces some incompatibilities with some latex bundle commands, for example, with the commands for references and citations.
Here is the error output (for getting the list of BiBTeX citations)
tm_dialog: failed to establish connection with TextMate. /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ui.rb:182:in `load': Cannot parse a NULL or zero-length data (OSX::PropertyListError) from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ui.rb:182:in `menu' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ui.rb:177:in `popen' from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/ui.rb:177:in `menu' from /tmp/temp_textmate.joS1lQ:12
similar for the internal references
All the best
Guido -- Guido Governatori http://www.governatori.net/Textmate