Visual select / paste behaviour

2006-07-28 Thread Roel Vanhout

Hi,

Take the following example:

file file_id=myidc:\test.txt/file

When the cursor is on the 'm' of 'myid' and I press 'vw', a word is 
selected in visual mode. However, the  at the end of 'myid' is also 
selected. How do I change the list of 'word separators'?


On a related note, when I have 'myid' selected and I want to replace it 
with the contents of the yank buffer, I press 'p'. But the original 
contents of the yank buffer are then replaced my 'myid', i.e. the text 
that was replaced in the paste operation. How do I change this 
behaviour? Do I have to write a macro to override the paste behaviour in 
visual mode or is there another way? Thanks.


cheers,

roel




Re: Visual select / paste behaviour

2006-07-28 Thread Jürgen Krämer

Hi,

Roel Vanhout wrote:
 
 Take the following example:
 
 file file_id=myidc:\test.txt/file
 
 When the cursor is on the 'm' of 'myid' and I press 'vw', a word is 
 selected in visual mode. However, the  at the end of 'myid' is also 
 selected. How do I change the list of 'word separators'?

to be exact 'w' in visual word does NOT select a word but it extends the
current selection to the START of the next word (for a definition of
word see :help word). So in your case 'viw' would be better. This
starts visual mode and selects the Inner Word. This works on any letter
of myid and does not select the following quote.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)



Re: Visual select / paste behaviour

2006-07-28 Thread Tim Chase

 file file_id=myidc:\test.txt/file

 When the cursor is on the 'm' of 'myid' and I press 'vw',
 a word is selected in visual mode. However, the  at the
 end of 'myid' is also selected. How do I change the list
 of 'word separators'?

Well, the answer to your question is that there's a setting
called 'iskeyword' to which you can add and from which you
can remove characters.  However, by default, it doesn't
include the double-quote character.  What you're seeing is
an expression of that range from the drop-point m *up to,
but not including* where the cursor is (on the quote).  If
you follow your vw example with y to yank it, and then
paste it elsewhere, you'll see that the selection was
accurately just myid, not myid

 On a related note, when I have 'myid' selected and I want
 to replace it with the contents of the yank buffer, I
 press 'p'. But the original contents of the yank buffer
 are then replaced my 'myid', i.e. the text that was
 replaced in the paste operation. How do I change this
 behaviour?

The best solution I know is to use

_p

instead of just p.  This sends the deleted text (the
stuff you previously had highlighted) into the black-hole
register, leaving your default register untouched.

Alternatively, register 0 is the last yanked text
register, which is unaffected by such deletes--only yanks.
Thus, you could use (and easily map)

0p

to always paste the last thing you yanked.  This has two
side effects of which it's best to be aware:  It does change
your default (unnamed) register to the most recently
replaced text; and if you delete something (rather than yank
something) with the intent to use it later for overwriting a
visual block, you'll get unexpected results, as you're
pasting the last *yanked* thing, rather than the last
*deleted* thing.

For more info, you can read at
:help _
:help 0
:help v_p

Hope this helps you find a solution to what you're trying to
do.

-tim








Re: Visual select / paste behaviour

2006-07-28 Thread Roel Vanhout

Tim Chase wrote:

  file file_id=myidc:\test.txt/file
  When the cursor is on the 'm' of 'myid' and I press 'vw',
  a word is selected in visual mode. However, the  at the
  end of 'myid' is also selected. How do I change the list
  of 'word separators'?
Well, the answer to your question is that there's a setting
called 'iskeyword' to which you can add and from which you
can remove characters.  However, by default, it doesn't
include the double-quote character.  What you're seeing is
an expression of that range from the drop-point m *up to,
but not including* where the cursor is (on the quote).  If
you follow your vw example with y to yank it, and then
paste it elsewhere, you'll see that the selection was
accurately just myid, not myid


Thanks, this is indeed the setting I'm looking for. However it seems 
that the w motion *is* inclusive, at least on my installation. Here's 
what :set iskeyword says:

iskeyword=@,48-57,_,192-255
(which is the default, I did a 'set nocp' to make sure it was reset to 
the default, as per the docs).
Now when I repeat putting the cursor on 'm' and pressing 'w', the  is 
selected, as confirmed by yanking and pasting and seeing 'myid' being 
pasted. This is not what the documentation says should happen, so I 
looking around for any mappings of w to something but as far as I can 
tell, no such mapping is available.

For the record, I'm using gvim 7 of may 7th, according to :version.
I've tried starting gvim without loading a vimrc, but I get the same 
behaviour. Anyone else seeing this? Am I picking up side effects from 
other settings somehow?



  On a related note, when I have 'myid' selected and I want
  to replace it with the contents of the yank buffer, I
  press 'p'. But the original contents of the yank buffer
  are then replaced my 'myid', i.e. the text that was
  replaced in the paste operation. How do I change this
  behaviour?
The best solution I know is to use
_p
For more info, you can read at
:help _
:help 0
:help v_p
Hope this helps you find a solution to what you're trying to
do.


Thanks, I'll investigate this, I think I can work something out from here.


cheers,

roel



Re: Visual select / paste behaviour

2006-07-28 Thread Jürgen Krämer

[Resending this because I noticed that the original mail had been
encoded with base64 by either my mail client or a server on the way
to the mailing list.]

Hi,

Roel Vanhout wrote:
 
 Take the following example:
 
 file file_id=myidc:\test.txt/file
 
 When the cursor is on the 'm' of 'myid' and I press 'vw', a word is 
 selected in visual mode. However, the  at the end of 'myid' is also 
 selected. How do I change the list of 'word separators'?

to be exact 'w' in visual word does NOT select a word but it extends the
current selection to the START of the next word (for a definition of
word see :help word). So in your case 'viw' would be better. This
starts visual mode and selects the Inner Word. This works on any letter
of myid and does not select the following quote.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)



Re: Visual select / paste behaviour

2006-07-28 Thread cga2000
On Fri, Jul 28, 2006 at 09:48:21AM EDT, Jürgen Krämer wrote:
 
 [Resending this because I noticed that the original mail had been
 encoded with base64 by either my mail client or a server on the way
 to the mailing list.]
 
 Hi,
 
 Roel Vanhout wrote:
  
  Take the following example:
  
  file file_id=myidc:\test.txt/file
  
  When the cursor is on the 'm' of 'myid' and I press 'vw', a word is 
  selected in visual mode. However, the  at the end of 'myid' is also 
  selected. How do I change the list of 'word separators'?
 
 to be exact 'w' in visual word does NOT select a word but it extends the
 current selection to the START of the next word (for a definition of
 word see :help word). So in your case 'viw' would be better. This
 starts visual mode and selects the Inner Word. This works on any letter
 of myid and does not select the following quote.
 
cool.

Thanks

cga