Author Topic: How to jump to the beginning/end of a wrapped line in soft wrap mode?  (Read 6315 times)

Ding Zhaojie

  • Senior Community Member
  • Posts: 194
  • Hero Points: 37
If I press the Home key, the cursor will jump to the beginning of line (or we can call it "paragraph" in soft wrap mode), but not the beginning of current wrapped line. The End key has the same problem.  How can I solve this? Thanks.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: How to jump to the beginning/end of a wrapped line in soft wrap mode?
« Reply #1 on: September 13, 2006, 10:01:10 PM »
If I press the Home key, the cursor will jump to the beginning of line (or we can call it "paragraph" in soft wrap mode), but not the beginning of current wrapped line. The End key has the same problem.  How can I solve this? Thanks.

I don't have time to write a macro for this right now but a possibility is to use the p_rel_line property.  p_rel_line is the line number relative to the top of the screen - so if the cursor does actually physically move up or down you can detect this  - except when the window also scrolls i.e. if the cursor is at the top or bottom of the window - (you could possibly also handle this case by doing the operation twice if you really wanted so that the window doesn't scroll on the second movement)

So very roughly, to implement "home" you could cursor left until either p_col becomes 1 or p_rel_line changes (you can then tell what the column number of the first wrapped character is), then search forward for the first non-space character  - something like that.  Or maybe just call begin-line-text-toggle (the home function) and check if p_rel_line changes, then call down(1,true) to move physically down one line - this won't leave the cursor in exactly the right column but you get the idea ...

Graeme

Ding Zhaojie

  • Senior Community Member
  • Posts: 194
  • Hero Points: 37
Re: How to jump to the beginning/end of a wrapped line in soft wrap mode?
« Reply #2 on: September 14, 2006, 04:08:44 AM »
If I press the Home key, the cursor will jump to the beginning of line (or we can call it "paragraph" in soft wrap mode), but not the beginning of current wrapped line. The End key has the same problem.  How can I solve this? Thanks.

I don't have time to write a macro for this right now but a possibility is to use the p_rel_line property.  p_rel_line is the line number relative to the top of the screen - so if the cursor does actually physically move up or down you can detect this  - except when the window also scrolls i.e. if the cursor is at the top or bottom of the window - (you could possibly also handle this case by doing the operation twice if you really wanted so that the window doesn't scroll on the second movement)

So very roughly, to implement "home" you could cursor left until either p_col becomes 1 or p_rel_line changes (you can then tell what the column number of the first wrapped character is), then search forward for the first non-space character  - something like that.  Or maybe just call begin-line-text-toggle (the home function) and check if p_rel_line changes, then call down(1,true) to move physically down one line - this won't leave the cursor in exactly the right column but you get the idea ...

Graeme


Thanks! Good idea.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: How to jump to the beginning/end of a wrapped line in soft wrap mode?
« Reply #3 on: September 14, 2006, 04:02:41 PM »
This is definitely a useful feature.  If this was trivial, it would have already been done.  The difficulty is in moving to the end of a soft wrap line.  Since the column position at the end of the line is the same as the column position at the beginning of the line, this feature requires a bit of work.  If there isn't already a feature request filed, I will file one.