Author Topic: Command to create selection similiar to next-paragraph  (Read 3792 times)

FreshDesh

  • Community Member
  • Posts: 13
  • Hero Points: 0
  • Make my own rules so I can break them.
Command to create selection similiar to next-paragraph
« on: March 16, 2012, 03:00:58 pm »
I like the functionality of next/prev-paragraph.  Is there a command that will create a selection in the same fashion that these commands traverse text? 

stay fresh,
Desh

Mike

  • SlickEdit Team Member
  • Community Member
  • *
  • Posts: 96
  • Hero Points: 19
Re: Command to create selection similiar to next-paragraph
« Reply #1 on: March 16, 2012, 03:24:47 pm »
'select-paragraph' will select the current paragraph and keep block selection on, at which point you can use next/prev-paragraph to adjust the selection block.

I just noticed that for select-paragraph, the status bar says "Mark set.  Ctrl+G Cancels mark" but in CUA it would actually be Ctrl+B.  Ctrl+G will try to find-next :-/

FreshDesh

  • Community Member
  • Posts: 13
  • Hero Points: 0
  • Make my own rules so I can break them.
Re: Command to create selection similiar to next-paragraph
« Reply #2 on: March 16, 2012, 03:37:02 pm »
thx!  it appears that i need to write a macro to combine the 2 commands.
« Last Edit: March 20, 2012, 07:27:38 pm by FreshDesh »

FreshDesh

  • Community Member
  • Posts: 13
  • Hero Points: 0
  • Make my own rules so I can break them.
Re: Command to create selection similiar to next-paragraph
« Reply #3 on: March 22, 2012, 09:58:38 pm »
nevermind, I still can't get the functionality that i'm looking for.  I'm pretty sure that i've had this behavior before. 

Go in to MS Word and use the Ctrl+Shift+Up/Down arrow keys to see what i'm looking for.  hero point every day for a week if you can help me out! 

Mike

  • SlickEdit Team Member
  • Community Member
  • *
  • Posts: 96
  • Hero Points: 19
Re: Command to create selection similiar to next-paragraph
« Reply #4 on: March 22, 2012, 10:14:10 pm »
Did you try this?
Load the following macro
Bind the select-next-paragraph to Ctrl+Alt+Shift+DownArrow
Bind the select-prev-paragraph to Ctrl+Alt+Shift+UpArrow

Pressing the key combination will select the next or previous paragraph, in the same fashion that the next/prev-paragraph commands traverse text.

==========

#include "slick.sh"
_command select_next_paragraph() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   execute('next-paragraph','a');
   execute('select-paragraph');
}

_command select_prev_paragraph() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   execute('prev-paragraph','a');
   execute('select-paragraph');
}

FreshDesh

  • Community Member
  • Posts: 13
  • Hero Points: 0
  • Make my own rules so I can break them.
Re: Command to create selection similiar to next-paragraph
« Reply #5 on: March 24, 2012, 04:55:26 pm »
that is getting close, but it removes the selection, and only selects a single paragraph.  This is not how Ctrl+Shift+Up/Down works in Outlook where the selection continues to expand paragraph by paragraph.

FreshDesh

  • Community Member
  • Posts: 13
  • Hero Points: 0
  • Make my own rules so I can break them.
Re: Command to create selection similiar to next-paragraph
« Reply #6 on: April 02, 2012, 02:25:41 pm »
bizzump

Mike

  • SlickEdit Team Member
  • Community Member
  • *
  • Posts: 96
  • Hero Points: 19
Re: Command to create selection similiar to next-paragraph
« Reply #7 on: April 03, 2012, 05:11:40 pm »
Ctrl+Shift+arrows in Outlook and MS Word (on my machine) only selects lines, appending them to the selected text.  (Not removing selection)

The only time I see Ctrl+Shift+arrow selecting a "paragraph" in Outlook, is when it is an email address header.

Are lines what you want, or do you want paragraphs to be selected?

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Command to create selection similiar to next-paragraph
« Reply #8 on: April 04, 2012, 05:21:24 am »
Ctrl+Shift+arrows in Outlook and MS Word (on my machine) only selects lines, appending them to the selected text.  (Not removing selection)

The only time I see Ctrl+Shift+arrow selecting a "paragraph" in Outlook, is when it is an email address header.

Are lines what you want, or do you want paragraphs to be selected?
Ctrl+Shift+Up/Down select paragraphs in Outlook and Word.
The only time it selects lines, is when the lines are paragraphs.

For example, often received emails may have explicit line breaks at the end of wrapped lines.  The sender's paragraph may have logically been composed of many lines, but it can get converted into a series of one-line-long paragraphs, which can still look like one paragraph since line breaks are typically invisible.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1189
  • Hero Points: 114
Re: Command to create selection similiar to next-paragraph
« Reply #9 on: April 04, 2012, 01:08:51 pm »
Is this a plain-text document with paragraphs separated by a single blank line?  If so, you could start by recording a macro with:

begin line/char select
search for: ^[ \t]*$ (Perl/Unix regex) (remember to set Look in to Current Buffer, not Current Selection)

That will select everything up to and including the blank line.  Same goes for prev, only search backwards.

Phil Barila

  • Senior Community Member
  • Posts: 742
  • Hero Points: 61
Re: Command to create selection similiar to next-paragraph
« Reply #10 on: April 04, 2012, 02:55:02 pm »
Ctrl+Shift+Up/Down select paragraphs in Outlook and Word.
The only time it selects lines, is when the lines are paragraphs.

For example, often received emails may have explicit line breaks at the end of wrapped lines.  The sender's paragraph may have logically been composed of many lines, but it can get converted into a series of one-line-long paragraphs, which can still look like one paragraph since line breaks are typically invisible.
As usual, chrisant is right.  ++HP.  If you have Outlook remove extra line breaks for you, paragraphs that have been wrapped at a specific column by the sender will get "unwrapped", and then Ctrl+Shift+arrow will highlight the whole paragraph.
I find the "unwrapping" unhelpful most of the time, so I leave it off.

Mike

  • SlickEdit Team Member
  • Community Member
  • *
  • Posts: 96
  • Hero Points: 19
Re: Command to create selection similiar to next-paragraph
« Reply #11 on: April 04, 2012, 02:58:56 pm »
Yes, I had line breaks like Chrisant pointed out.