NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Surround code


Joined: 15 Jun 2006
Posts: 25
Reply with quote
Hi!

We just downloaded the trial and the whole team loves this editor, it´s fantastic, we will switch to PhpED right away.
With that said I´m requesting a feature: Surround code.
This is a feature that the Java IDE - IDEA has.

1. Select a piece of code and hit the "Surround code" shortcut.
2. Select the "surround type" for example "try - catch" or "try - finally"
3. The selected code is indented and try/catch brackets and inserted.

The code:
Code:

    echo "i´m a lobster";


would after surrounding code be:

Code:

   try {
        echo "i´m a lobster";
    } catch(Exception $e) {
        print($e->getMessage());
    }


It´s very useful if you wan´t to add a try/catch or similar to a piece of code.
I guess that the template feature could be used if there´s a way of not replacing the selected code like putting a "@1" (or similar)" that substitutes the selected code.

This is just my 2 cents. =)
View user's profileFind all posts by pommesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Hmm, it's quite simple, especially taking into account that we just implemented such "surrounding" for Edit->Html tags.
Probably, we'll do it for code templates soon too.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 15 Jun 2006
Posts: 25
Reply with quote
Any news on this? Smile
View user's profileFind all posts by pommesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
It will be available in 4.5.1, I think.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 15 Jun 2006
Posts: 25
Reply with quote
ok, sweet!

but you mean 4.6.1, right?
View user's profileFind all posts by pommesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
ah, yes sure 4.6.1
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 15 Jun 2006
Posts: 25
Reply with quote
Hi!

Did this feature make it into 4.6.1? I´m afraid I can´t find it.

regards,
pommes
View user's profileFind all posts by pommesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
well, try the following:

enter code template (tools->settings) like below:

Code:
try {
    |
} catch(Exception $e) {
    print($e->getMessage());
}


create new file, with content
Code:
<?
  echo "i´m a lobster";
?>


select content of the 2nd line (starting with echo and ending up with semicolon),
press Ctrl-J and select your template.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 15 Jun 2006
Posts: 25
Reply with quote
Ah, sweet! That´s obvious! Great feature =)
View user's profileFind all posts by pommesSend private message


Joined: 15 Jun 2006
Posts: 25
Reply with quote
Awesome feature, but:

Select Code
Pressing Ctrl+J
Pressing keys t-r-y to autoselect "trycatch"-template, the selected code is removed.

when:

Select Code
Pressing Ctrl+J
Using mouse to select "trycatch" works just fine.

/pommes
View user's profileFind all posts by pommesSend private message


Joined: 15 Jun 2006
Posts: 25
Reply with quote
*bumping the thread* This has probably become a bug-report now. =)
View user's profileFind all posts by pommesSend private message
Surround code
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic