Hi there
Am wanting to create a macro or snippet to allow me to comment out a selection thus:
/* commented selection */
But am a little unclear if this is via a macro or a snippet. Either way, I'm having trouble seting this up.
Any clues appreciated...
bongoman
Got it. It's a command. I now realise I can echo text back to replace selected text. Excellent.
bongoman
On Sun, 10 Oct 2004 08:27:07 +1000, bongoman infolists@gmail.com wrote:
Hi there
Am wanting to create a macro or snippet to allow me to comment out a selection thus:
/* commented selection */
But am a little unclear if this is via a macro or a snippet. Either way, I'm having trouble seting this up.
Any clues appreciated...
bongoman
Me again.
Now I'm trying to create a command to comment out a single line thus: // commented line
I'm not a shell scripter but am trying this:
set oldLine = $TM_CURRENT_LINE set newLine = "// $oldLine" echo -n "$newLine"
But no go. What I want to achieve is to comment out the current line, not a selected line. So wherever the caret is when I invoke the command gives me a commented single line.
So whether this script is OK or not I'm a little stuck on what my input and output should be for such a command.
Any clues appreciated.
bongoman
On Sun, 10 Oct 2004 09:54:43 +1000, bongoman infolists@gmail.com wrote:
Got it. It's a command. I now realise I can echo text back to replace selected text. Excellent.
bongoman
On Sun, 10 Oct 2004 08:27:07 +1000, bongoman infolists@gmail.com wrote:
Hi there
Am wanting to create a macro or snippet to allow me to comment out a selection thus:
/* commented selection */
But am a little unclear if this is via a macro or a snippet. Either way, I'm having trouble seting this up.
Any clues appreciated...
bongoman
On 10. Oct 2004, at 5:07, bongoman wrote:
But no go. What I want to achieve is to comment out the current line, not a selected line. So wherever the caret is when I invoke the command gives me a commented single line.
Record it as a macro, do something like:
start macro recording, select line, (option-l or Edit / Select / Line), Text / Filter Through Command: 'echo // $TM_CURRENT_LINE' arrow left (just to unselect), stop macro recording.
As mentioned in the other email, you can also use regex-replace instead of shell-piping -- only a matter of personal preferences I guess ;)
ind regards Allan
On 10. Oct 2004, at 1:54, bongoman wrote:
Got it. It's a command. I now realise I can echo text back to replace selected text. Excellent.
Another possibility is recording a macro that uses regex search'n'replace with scope set to selection.
This allows to check for conditions like the 'Selection as Anchor' which does:
findString: ^(.*@.*..*)|.*$ replaceString: <a href="(?1mailto\:$0:$0.html)">$0</a>
The find string matches an email as capture 1 _or_ it matches anything.
The format string makes it into an anchor and _if_ there is a first capture, it prefixes $0 (the entire match) with mailto:, otherwise it uses .html as suffix.
Kind regards Allan