Textmate editing 2 words at same time - ruby-on-rails

I am not 100% sure if this is the right place to be posting this question, but I could not think of anywhere else.
I having been using textmate for around 6 months to write Ruby on Rails applications.
The snippets and stuff are nice. I am wondering if it is possible to edit to words at the same time. I am using the mcol snippet which generates a add_column and remove_column in a database migration.
When the code is generated it highlights the table_name and changes both occurences of the word table_name when you start typing.
Hoping that this can be done to any word that you select.
Cheers
Eef

Since the whole idea of TextMate is to have an editable editor(!), if you look at the HTML bundle, the shortcut ctrl-shift-w invokes this:
<${1:p}>$TM_SELECTED_TEXT</${1/\s.*//}>
So, to add a custom shortcut to wrap a selection in a pair of editable text strings (which is what you want, I think?), go to Bundles > Show Bundle Editor then choose New Snippet from the add + button (bottom left) and use (e.g.):
${1:editme}$TM_SELECTED_TEXT${1/\s.*//}
where 'editme' is the default 'doubly-editable' value. If you add a new snippet shortcut in the 'Key Equivalent' field (I used ctrl-shift-alt-W) you can then wrap any selection in an editable pair of words. Depending on what you need, the same syntax might be expanded to match your requirements?
Note: once the shortcut is allocated, you can't edit a snippet in place - you need to start again (I think - couldn't find a way around that).

Related

Notepad++ like editor with with macrosed text replacements for faster coding

Is there any editor or add-on/plugin which replaces some keywords with prepared snippets in place of written keyword.
For example i'm typing key1 and it's instantly or after a space is replaced with snippet that is assigned to this keyword.
I saw some tutorial from Jeffrey Way long ago, but can't find it now. :s
Thanks ;)
FingerText for Notepad++ pretty much does what you want.
Just use Tab after typing in the keyword you set up for the snippet, and it'll replace it with the snippet.
The Zeus editor has a template feature that does exactly this. A template is a keyword with an associated code snippet and typing in a keyword followed by the space key results in the keyword being replaced by the associated code snippet.
Try installing AutoHotkey version 1.1.19.03 or greater.
One thing it can do is look for sequences of keyboard characters and replace them with other sequences on the fly. As soon as it sees a sequence it will replace it. No activating character is required.
To set up the replacement definitions:
Right click on the Desktop
New
AutoHotkey Script
This will create a template for
your script with the name New AutoHotkey Script.ahk
Edit New AutoHotkey Script.ahk with Notepad++
Put your key snippet lines at
the end, like so:
:*:key1::snippet for key1
:*:key2::snippet this time for key2
Save As My Snippet definitions.ahk
To invoke it: Double click My Snippet definitions.ahk
You can control AutoHotkey by right clicking on its icon on the taskbar.

How do I make Beyond Compare ignore certain differences while comparing versions of Delphi Form Files

I use Beyond Compare (version 3.1.10) to compare different versions of Delphi Form Files, but I don't want to see differences concerning ExplicitTop, ExplicitLeft, ExplicitHeight and ExplicitWidth.
Details:
These lines will always begin with a number of whitespace characters, then "ExplicitXXX = " and a number. Older versions of Delphi didn't have these lines, so I want to ignore differences where these lines are added to the newest version, and I also want to ignore differences where the number has changed.
Does anyone know how to do this?
Edit:
Duplicate (more or less) of:
How do I configure BeyondCompare to ignore SCM replaced text in comments?
Load a pair of DFM files showing the difference.
Click the Session Settings button (aka Rules w/ umpire icon) or use the Session->Session Settings menu item.
Switch to the Importance tab then click the Edit Grammar... button to open a second dialog.
Click the New... button below the top listbox to open a third dialog.
Change the Element Name option to something like Explicit*, change the Text Matching to Explicit(Left|Top|Width|Height) = \d+ and check the Match character case and Regular expression checkboxes, then click Ok, then click Ok again in the second dialog.
Explicit* should now appear in the original dialog's Grammar Elements list. Uncheck it, then change the combobox at the bottom of the dialog from Use for this view only to Update session defaults.
I don't use Beyond Compare, but if you want to have newer versions of Delphi stop adding the (IMO useless) Explicit* properties, you can use Andreas Hausladen's DDevExtensions
In my case (C#), I wanted to ignore the entire line which contained namespaces (and thus, using's) which I changed.
(Referenced Walkthrough - Ignore entire line if text exist in line
ie.
namespace INSERT.NAMESPACE.HERE
changed to
namespace INSERT.NAMESPACE.HERE.NEW
To do that
In step 5. of Craig's solution, change the Text Matching to
" .\*INSERT.NAMESPACE.HERE.\* "
(include the quotes)
That's it.
Craig Peterson's answer is correct.
N.B. However! The tab 'importance' is not always visible from Session/Session-settings. Always, from inside a Folder list view, it will not be there. It seems there are certain filetypes that do not have it either, though I'm less clear on that. BC has so many options and plugins I bet there is a workaround, but for me I have been ok so far.
http://www.scootersoftware.com/vbulletin/showthread.php?t=8457

Is there a shortcut in Textmate to wrap selection with multiline comment?=begin and =end

I want a shortcut in Textmate to wrap the selected text with a ruby multiline comment -- '=begin' and '=end'.
It doesn't look like there is an existing one. Anyone know how to make one?
Finally figure it out, mostly by luck. I still wish I could find where the shortcut was defined.
However, it's ⌥⌘/
My bundle always uses the single-line comments, even when I select multiple lines. I'm sure your answer lies somewhere in Bundles > Bundle Editor > Ruby > Comments.

Pretty Print for (Informix-)4gl code

i'm searching for a pretty print program (script, code, whatever) for Informix-4GL sources.
Do you know any ? Than you, Peter.
Have you looked at the IIUG (International Informix User Group) software archive? There are two pretty printers there (of indeterminate quality).
The other place to look would be the Aubit4GL site - an open source variant of I4GL. Again, I'm not sure that they have a pretty-printer, but it might be something they have (though a casual check doesn't show one).
I don't know if anyone is reading this post anymore, but the easiest way to get some kind of nice "pretty print" of 4gl code is to view it in the Openedge Developer Studio, then use ctrl-I to set indention. You can adjust indention in the editor settings by saying the length of "tabs". (default is 4, I use 3)
Then do a ctrl-shift-f to make all command words uppercase.
Next, you can condense the code a few lines by moving all the "DO:" statements up a line next to the "THEN" statement with this regular expression search and replace.
ctrl-f:
search "\s*\n\s*DO[:]"
replace " DO:"
make sure you click the checkbox marked regular expressions.
At this point the code is nice and tidy.
Do a ctrl-a and ctrl-c to copy it to the clipboard.
paste it in Outlook as an email without sending. Print it in color.

Delphi Short Cut to add Date and Name Comment

Does anyone know of a short cut to place my name and the date where the cursor is i.e.
//021208 DarkAxi0m
so i don't keep check what the date is when i'm adding comments.
Im using Delphi7, with CnPack And GExperts Installed.
I think it should be able to be done with one of those experts.
I use GExperts to do this, like so:
in the
GExperts\Configuration
Select the Editor Experts tab.
In the list of experts, select
Insert Date\Time
Click on the configuration, insert the desired text:
'//' ddmmyy 'DarkAxi0m: '
//021208 DarkAxi0m:
After, to insert your new Date name comment all you need to do is:
ctrl+alt+a
I setup most programmers at the job like that.
It is also simple to do with GExperts' Expand Macro Template (found in Editor Experts).
I use this expansion to insert yyyy-mm-dd at the current position:
%YEAR%-%MONTH%-%DAY%|
For a solution that will work in most applications under Windows, not only in Delphi, you can use Authotkey (free, autohotkey.com). One of its many features is the ability to expand strings that you type - typically used for autocorrecting typos.
I start all my shortcut strings with a semicolon, since it practically never leads strings I type in real life, so in your example, to insert a comment-date-username sequence, I would want to type semicolon, slash, slash:
;//
The Authotkey script (which you can put in an .ahk text file and add the file to Autostart) would look like this:
::;//:: ; this means: when I type ";//", do what follows
FormatTime, curDate,, yyyy-MM-dd ; the double comma is intended
SendInput // %curDate% %A_UserName% ; variable expansion
return
This produces the following output:
// 2008-12-05 moodforaday
AHK syntax is a little dense, but there is an extensive help file.
On edit: this script could be expanded to apply the correct comment syntax depending on the IDE you are working in at the moment. You would detect active window title, find a signature substring ("Delphi") and choose the proper comment character(s). This way you could type the same hotstring to insert your comment regardless of the current IDE or language. You can also use SendInput to position the caret the way Delphi templates do.
Never mind found one in CnPack/Soure Templates
Added the template
//%Date% DarkAxi0m
Note: i should look in the menus more closely
You might also look at the Live Templates feature, which can be scripted to do just what you want:
http://cc.codegear.com/Item/24990
Don't be put off by the name, it includes a template script to include the date, time, including the ability to format it as you want.
Here is a variation with GExperts (www.gexperts.org) that makes it easy to search for changes based on developer or date.
Example of output and comment:
//07.25.2009 (SLB20090725) - Added 3rd optional parameter.
Besides an easily readable date I can easy search for comments programmer, by year, year+month etc.)
For example I can search for (SLB200905 for any comments I logged in May of 2009.
To do:
Under the GExperts menu open Configuration... (at the bottom of the list) then select the Editor Experts tab.
Locate 'Insert Date/Time' and double click on it.
//mm.dd.yyyy '(ABC'yyyymmdd') -'
Where ABC is the programmers name, initials, id, or whatever.
Then use Ctrl-Alt-A when in Delphi's IDE to insert
This should work in any verison of Delphi supported by GExperts.

Resources