Author Topic: Horizontal Dynamic Surround  (Read 879 times)

mitcheljh

  • Community Member
  • Posts: 52
  • Hero Points: 2
Horizontal Dynamic Surround
« on: October 13, 2009, 04:00:24 pm »
Something that would be very nice, would be Horizontal Dynamic Surround for certain languages like HTML.
How many times do you run into a situation like this...  you have a line which contains the following...
This is a html line in which the work, emphasized need to be tagged.
So, now you want to surround the word 'emphasized' with the tags.

What we do now, is add the tags in front of the word, so our sentence above now becomes...
>This is a html line in which the work, emphasized need to be tagged.
If you're like me, you then select and drag the desired word or phrase (emphasized) between the tags.
But, it would be really great if a 'horizontal Dynamic Surround' would take effect when ever you added inline tags, so then you could just use your right arrow to include the word/phrase inside the newly added tag.

jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: Horizontal Dynamic Surround
« Reply #1 on: October 13, 2009, 06:08:14 pm »
Tagging - not that I don't get your point (I do, and I like it) - but you can save a few keystrokes (perhaps) by highlighting what you want, then right-click, Surround Selection With from the context menu, select emphasis.  I found myself doing this so much (creating links) that I bound a recorded macro to a key combo to do just this.  (I still like the arrow-keys though - it could be even faster)

Jim.

MartyL

  • Senior Community Member
  • Posts: 162
  • Hero Points: 27
  • Synergex
Re: Horizontal Dynamic Surround
« Reply #2 on: October 13, 2009, 09:22:01 pm »
mitcheljh,

There is some existing functionality that would really help with what you're doing. It's called complete-next. In the default SlickEdit bindings, it's Ctrl+Shift+Period. You'll also want complete-more, which defaults to Ctrl+Shift+Space.

Code: [Select]
This is a html line in which the work, emphasized need to be tagged.
As you normally would, put your cursor before emphasized and type your tag.

Code: [Select]
This is a html line in which the work, <em></em>emphasized need to be tagged.
Place your cursor in the middle of the tags and do complete-next. At this point, it's going to highlight the "em" in , not really what you want. So do complete-next again, and you should see this:

Code: [Select]
This is a html line in which the work, <em>emphasized</em>emphasized need to be tagged.
But now you have two emphasized texts. Not really what you want. At this point you could use cut or "delete-selection" to clear the second emphasized.

Code: [Select]
This is a html line in which the work, <em>emphasized</em> need to be tagged.
On to making it work for phrases. Let's say that you wanted "emphasized need to be" as the phrase you wanted to wrap. Get your line back to this point:

Code: [Select]
This is a html line in which the work, <em></em>emphasized need to be tagged.
Place your cursor between the tags as you did before and complete-next twice to highlight emphasized. From this point, you can highlight additional words with complete-more. Since you want three more words, press complete-more (Ctrl+Shift+Space) three times.

Code: [Select]
This is a html line in which the work, <em>emphasized need to be</em>emphasized need to be tagged.
Once again, do a cut or a delete-selection (no default key) to clear the leftover words.

Code: [Select]
This is a html line in which the work, <em>emphasized need to be</em> tagged.
It sounds like a lot of work, but in practice it's usually faster and easier than dragging your phrase into the tags. Once you get used to it, it can be applied to all sorts of code editing.