cw change till not alphabet letter?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

cw change till not alphabet letter?

Vincent Xu

if the cursor in at the first of the following line, eg. "s"
self.InsertColumn(5, "Locked")
cw will erase all words up to ',', is there a way to change the cw
behavior so that it will stop at any non-alphabet (number, signs,
etc)?

TIA.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: cw change till not alphabet letter?

Gary Johnson-4

On 2009-02-05, ViX <[hidden email]> wrote:
> if the cursor in at the first of the following line, eg. "s"
> self.InsertColumn(5, "Locked")
> cw will erase all words up to ',', is there a way to change the cw
> behavior so that it will stop at any non-alphabet (number, signs,
> etc)?

By default, cw will stop at the first non-word character, which in
this case is the '.'.  The behavior you're seeing results from
something having changed the 'iskeyword' option.  You can find the
culprit by executing

    :verbose set isk?

By knowing where 'iskeyword' is being set, you can figure out an
appropriate way to fix the problem.

See

    :help iskeyword

HTH,
Gary



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: cw change till not alphabet letter?

Tim Chase
In reply to this post by Vincent Xu

ViX wrote:
> if the cursor in at the first of the following line, eg. "s"
> self.InsertColumn(5, "Locked")
> cw will erase all words up to ',', is there a way to change the cw
> behavior so that it will stop at any non-alphabet (number, signs,
> etc)?

What's your value returned by

   set isk?

With factory-default settings in your scenario, using "cw" will
delete "self" (up to the period) rather than to the comma.  Using
"cW" will delete as you describe (up to the next whitespace).
Try starting vim with

    vim -u NONE

and see if the behavior persists.  You can compare the resulting
values for 'iskeyword' to see if some script has monkeyed with
the settings.  You can even try

   :verbose set isk?

to see the culprit.

-tim




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: cw change till not alphabet letter?

Tony Mechelynck
In reply to this post by Vincent Xu

On 05/02/09 16:59, ViX wrote:
> if the cursor in at the first of the following line, eg. "s"
> self.InsertColumn(5, "Locked")
> cw will erase all words up to ',', is there a way to change the cw
> behavior so that it will stop at any non-alphabet (number, signs,
> etc)?
>
> TIA.

You can create your own "change" command, and optionally map it to a
key, for instance as follows:

        :nmap  <F5>  c/[^[:alpha:]]<CR>

Known bug: the above won't stop at a linebreak. With
c/\_[^[:alpha:]]<CR> instead, it will not replace a linebreak but
neither will it replace the last character on a line even if it is
alphabetic.


Best regards,
Tony.
--
User:       I'm having problems with my text editor.
Help desk:  Which editor are you using?
User:       I don't know, but it's version VI (pronounced: 6).
Help desk:  Oh, then you should upgrade to version VIM (pronounced: 994).

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: cw change till not alphabet letter?

Tim Chase

> :nmap  <F5>  c/[^[:alpha:]]<CR>
>
> Known bug: the above won't stop at a linebreak. With
> c/\_[^[:alpha:]]<CR> instead, it will not replace a linebreak but
> neither will it replace the last character on a line even if it is
> alphabetic.

And if you want it to respect line-breaks, you could do something
like:

   /\%#[[:alpha:]]*/e

-tim




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: cw change till not alphabet letter?

Vincent Xu
In reply to this post by Vincent Xu

I tried cw on my laptop with vim7, it really just change the "self", i
think my vimrc (vim6.x) at work is mess up, i will try to have a look
next week. Thanks you guys for the isk and the nmap info.

Best,
Vincent
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: cw change till not alphabet letter?

Tony Mechelynck

On 07/02/09 02:44, ViX wrote:
> I tried cw on my laptop with vim7, it really just change the "self", i
> think my vimrc (vim6.x) at work is mess up, i will try to have a look
> next week. Thanks you guys for the isk and the nmap info.
>
> Best,
> Vincent

You might start by getting a recent version of Vim at work; and if you
don't have the keys to directories accessible by everyone, you can
always install it into a subdirectory of your home directory. Or else,
you can try to convince someone who does have the keys that 6.x is
really an old model and that he would do everyone a favour by installing
a recent 7.2.x (last I saw was 7.2.102) where everyone can get at it.

Best regards,
Tony.
--
 From too much love of living,
 From hope and fear set free,
We thank with brief thanksgiving,
Whatever gods may be,
That no life lives forever,
That dead men rise up never,
That even the weariest river winds somewhere safe to sea.
                -- Swinburne

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---