Re: Go to start of visual selection

2007-05-16 Thread Andy Wokula

Andy Wokula schrieb:

Tim Chase schrieb:

How can I move the cursor the start of the visual selection?
With the o command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The ` motion
followed by gv sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

which gives you a Go to the Top and Go to the Bottom mapping 
within visual mode.


It can be a little funky in blockwise visual-mode, if your ' and ' 
points are top-right and bottom-left (rather than top-left and 
bottom-right), as the top will go to the top-right, not the 
top-left.  I haven't figured out a good way to do this without 
considerably more code in the mapping (save the column of ' and then 
gvO to go back to visual-mode but in the other corner and then 
compare the columns to see which you want, perhaps needing to switch 
back...it's ugly).


However, it should work fine in character-wise and line-wise visual 
modes.


HTH,

-tim


I don't understand why this works.

There must be a difference between
`v`
and
:normal `v`

v defines a new visual area and overwrites the `,` markers.  Why
does ` after :normal move the cursor to the start of the
_previously_ selected visual area?

Thx,
Andy


Ah, with a later Vim7 there is no difference any more.
Obviously this has been fixed with patch 125, dated August 2006.
Ok, this took three months till I got it ...

--
Regards,
Andy


Re: Go to start of visual selection

2007-02-06 Thread Tim Chase

 vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
 vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

 I don't understand why this works.

 There must be a difference between
`v`
 and
:normal `v`

 v defines a new visual area and overwrites the `,`
 markers.  Why does ` after :normal move the cursor to
 the start of the _previously_ selected visual area?

Sorry it's taken me a while to get back on this...life got a
little crazy.

Buried away in the help just above

:help :map-verbose

and in the section

:help map-listing

one finds this little morsel of help:

Note: When using mappings for Visual mode, you can use
the ' mark, which is the start of the last selected
Visual area in the current buffer |'|.

It's also possible to read the help at

:help '

either way, as it refers to the last selected visual area
which in visual-mode could mean either the area selected
before the the one I'm currently in, or the current visual
selection which is now the 'last selected visual area'
because I'm now doing something other than selecting.  It
might help to have an extra sentence at this help to say
something like

If you are currently in visual mode, this refers to the
beginning/end of the *previous* visual selection

Hope this helps shed light on your question rather than
muddy the waters.

-tim







Re: Go to start of visual selection

2007-02-04 Thread Andy Wokula

Tim Chase schrieb:

How can I move the cursor the start of the visual selection?
With the o command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The ` motion
followed by gv sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

which gives you a Go to the Top and Go to the Bottom mapping within 
visual mode.


It can be a little funky in blockwise visual-mode, if your ' and ' 
points are top-right and bottom-left (rather than top-left and 
bottom-right), as the top will go to the top-right, not the top-left.  
I haven't figured out a good way to do this without considerably more 
code in the mapping (save the column of ' and then gvO to go back to 
visual-mode but in the other corner and then compare the columns to see 
which you want, perhaps needing to switch back...it's ugly).


However, it should work fine in character-wise and line-wise visual modes.

HTH,

-tim


I don't understand why this works.

There must be a difference between
`v`
and
:normal `v`

v defines a new visual area and overwrites the `,` markers.  Why
does ` after :normal move the cursor to the start of the
_previously_ selected visual area?

Thx,
Andy

--
kühl, @vim.org ist wieder zurück

EOF






___ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de


Re: Go to start of visual selection

2007-02-04 Thread Andy Wokula

Tim Chase schrieb:

How can I move the cursor the start of the visual selection?
With the o command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The ` motion
followed by gv sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

which gives you a Go to the Top and Go to the Bottom mapping within 
visual mode.


It can be a little funky in blockwise visual-mode, if your ' and ' 
points are top-right and bottom-left (rather than top-left and 
bottom-right), as the top will go to the top-right, not the top-left.  
I haven't figured out a good way to do this without considerably more 
code in the mapping (save the column of ' and then gvO to go back to 
visual-mode but in the other corner and then compare the columns to see 
which you want, perhaps needing to switch back...it's ugly).


However, it should work fine in character-wise and line-wise visual modes.

HTH,

-tim


Works fine at least for character-wise visual mode, thanks! :-)
IMHO, this little basic feature should be included in Vim.

Regards,
Andy

--
EOF




___ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de


Go to start of visual selection

2007-02-01 Thread Andy Wokula

How can I move the cursor the start of the visual selection?  With the
o command, yes.  But how can I make sure the cursor is at the start
while visual mode is on?  The ` motion followed by gv sets the 
cursor back to the end if it was there.


Thx, Andy

--
EOF





___ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de


Re: Go to start of visual selection

2007-02-01 Thread Tim Chase

How can I move the cursor the start of the visual selection?
With the o command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The ` motion
followed by gv sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

which gives you a Go to the Top and Go to the Bottom mapping 
within visual mode.


It can be a little funky in blockwise visual-mode, if your ' and 
' points are top-right and bottom-left (rather than top-left and 
bottom-right), as the top will go to the top-right, not the 
top-left.  I haven't figured out a good way to do this without 
considerably more code in the mapping (save the column of ' and 
then gvO to go back to visual-mode but in the other corner and 
then compare the columns to see which you want, perhaps needing 
to switch back...it's ugly).


However, it should work fine in character-wise and line-wise 
visual modes.


HTH,

-tim






Re: Go to start of visual selection

2007-02-01 Thread A.J.Mechelynck

Tim Chase wrote:

How can I move the cursor the start of the visual selection?
With the o command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The ` motion
followed by gv sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

which gives you a Go to the Top and Go to the Bottom mapping within 
visual mode.


Won't they move the boundary of the visual area together with the cursor?



It can be a little funky in blockwise visual-mode, if your ' and ' 
points are top-right and bottom-left (rather than top-left and 
bottom-right), as the top will go to the top-right, not the top-left.  
I haven't figured out a good way to do this without considerably more 
code in the mapping (save the column of ' and then gvO to go back to 
visual-mode but in the other corner and then compare the columns to see 
which you want, perhaps needing to switch back...it's ugly).


However, it should work fine in character-wise and line-wise visual modes.

HTH,

-tim







Best regards,
Tony.


Re: Go to start of visual selection

2007-02-01 Thread Tim Chase

vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

which gives you a Go to the Top and Go to the Bottom mapping within 
visual mode.


Won't they move the boundary of the visual area together with the cursor?


Not from my testing...

[ed: a hush falls over the mailing-list...Tim actually tested 
this response?! :) ]


Perhaps a diff. setting between our setups if you're experiencing 
drifting?


Other than the peculiar caveat regarding blockwise visual mode, 
it worked for me.  Even in blockwise mode, it successfully went 
to the top, but wasn't always the top-*left* anchor.


Note that the  and  marks are jumped-to with the back-tick 
(rather than a regular apostrophe) which remembers column 
information as well, so when gt is run/expanded/executed, it


1) leaves visual mode
2) jumps to the exact anchor position of the bottom/top mark
3) enters the previous visual-mode as returned by the 
visualmode() function
4) and then jumps to the previous exact anchor position of the 
top/bottom mark


-tim








Re: Go to start of visual selection

2007-02-01 Thread Bill McCarthy
On Thu 1-Feb-07 11:51am -0600, Tim Chase wrote:

 vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
 vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

Why do you use `lt instead of just ` ?  Just a matter of
preference?

-- 
Best regards,
Bill



Re: Go to start of visual selection

2007-02-01 Thread Tim Chase
 vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
 vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr
 
 Why do you use `lt instead of just ` ?  Just a matter of
 preference?

Depending on what follows the

`

vim may try to interpret it as a character-notation.  I prefer
not to have to think about it, so just like with HTML entities
when I write HTML, it's now hard-wired that, when writing
mappings, I use lt (and I get stung enough with | vs. bar
 that I tend to err on the side of using the  notation when I
don't have to, just so I don't have to burn brain-cells thinking
about it case-by-case.

-tim









Re: Go to start of visual selection

2007-02-01 Thread Yegappan Lakshmanan

Hi Bill,

On 2/1/07, Bill McCarthy [EMAIL PROTECTED] wrote:

On Thu 1-Feb-07 11:51am -0600, Tim Chase wrote:

 vnoremap gt esc`:exec 'norm '.visualmode().'`lt'cr
 vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

Why do you use `lt instead of just ` ?  Just a matter of
preference?



The following text describing when to use lt in a map is taken
from the Vim keymap tutorial which is available at:

http://www.geocities.com/yegappan/vim_keymap.html


When Vim parses a string in a map command, the \... sequence of characters is
replaced by the corresponding control character. For example, let us
say in insert
mode you want the down arrow key to execute C-N when the insert complete
popup menu is displayed. Otherwise, you want the down arrow key to move the
cursor one line down. You can try the following command (which doesn't work):

   :inoremap Down C-R=pumvisible() ? \C-N : \DownCR

When parsing the above command, Vim replaces C-N and Down with the
corresponding control characters. When you press the down arrow in insert
mode, as there are control characters in the expression now, the
command will fail.

To fix this, you should escape the  character, so that Vim will not
replace \C-N with the control character when parsing the command. The
following command works:

   :inoremap Down C-R=pumvisible() ? \ltC-N : \ltDownCR

With the above command, Vim will use the control character only when the map
is invoked and not when the above command is parsed.




If the flag 'B' is present in 'cpoptions', then the backslash
character is not treated
as a special character in map commands. For example, let us say you want to
create an insert-mode map for the F6 key to insert the text Press Home to
go to first character. For this, you can try using the following command:

   imap F6 Press Home to go to first character

When you press F6 in the insert mode, the Home in the above map will
cause Vim to move the cursor to the first character in the line and insert the
reminder of the text there. To literally enter the text Home, you need
to escape it:

   imap F6 Press \Home to go to first character

If the flag 'B' is not present in 'cpoptions', then the above map command will
insert the correct text. If the flag 'B' is present, then the
backslash character is
not treated as a special character and the above map will not insert
the correct
text. To treat Home literally independent of the 'cpoptions' setting, you can
use the following command:

   imap F6 Press ltHome to go to first character

In the above command, the notation lt is used for  in Home.


- Yegappan