Re: Matching non-capitalized words?

2006-07-26 Thread Tim Chase

:%s/\[a-z]\+\//gI


another option is to include \C in the regular expression itself:

:%s/\C\[a-z]\+\//g



One should be careful about this, as the help states:

:help /\C


Note that 'ignorecase', \c and \C are not
used for the character classes.


And when you look up

:help /character-class

it shows you what's considered a character class.  I don't know 
if the [...] notation is considered a character-class or not, but 
the \u \l etc are listed there.


Just one of those things to watch out for with the \c and \C that 
don't seem to apply with regards to the I flag.  Or maybe they 
do with the I flag too?  The docs leave a bit of a gap here 
that could go either way.


-tim








Re: Matching non-capitalized words?

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

Hi,

Tim Chase wrote:
 :%s/\[a-z]\+\//gI
  another option is to include \C in the regular expression itself:
 
  :%s/\C\[a-z]\+\//g
 
 One should be careful about this, as the help states:
 
 :help /\C
 
 
   Note that 'ignorecase', \c and \C are not
   used for the character classes.

this means that \u always matches uppercase characters regardless of
whether ignorecase is set or not. \c is (at least in this case)
equivalent to setting ignorecase before search -- \u still matches
only uppercase letters. Because \C is used to make a pattern independent
of the current value of ignorecase, \u does not change when used with
\C either.

 And when you look up
 
   :help /character-class
 
 it shows you what's considered a character class.  I don't know 
 if the [...] notation is considered a character-class or not, but 
 the \u \l etc are listed there.

[...] is not considered a character class but a collection. As such it
behaves differently depending on the current value of ignorecase. If
set [A-Z] matches lowercase letters, too, as is the case when \c is
included in the search pattern.

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)



Matching non-capitalized words?

2006-07-25 Thread William O'Higgins Witteman
How would I match (and then delete) all of the words in a buffer that
are not capitalized?  Thanks.
-- 

yours,

William


RE: Matching non-capitalized words?

2006-07-25 Thread Halim, Salman
Make sure 'ignorecase' is off:

:set noignorecase

:%s/\[a-z]\+\//g

Salman. 

 -Original Message-
 From: William O'Higgins Witteman [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, July 25, 2006 4:24 PM
 To: vim
 Subject: Matching non-capitalized words?
 
 How would I match (and then delete) all of the words in a 
 buffer that are not capitalized?  Thanks.
 -- 
 
 yours,
 
 William
 


Re: Matching non-capitalized words?

2006-07-25 Thread Tim Chase

Make sure 'ignorecase' is off:

:set noignorecase

:%s/\[a-z]\+\//g


If you don't want to bung with your vim-wide (or bufferwide) 
settings, you can always just change your :s to include the I flag.


:%s/\[a-z]\+\//gI

Additionally, this will not find camel-case words, such as 
strFooBarBaz (which can be common if your source text is code)


To accomodate that, you can use

:%s/\\l\w*\//gI

(that is backslash ell not backslash one, which is a slightly 
shorter notation for [a-z], and may have some unicode plusses 
to it)


You can learn more at

:help :s_flags (and scroll down to the I)
:help /\l
:help /\w

to tailor the regexp for exactly what you're hunting.

-tim






Re: Matching non-capitalized words?

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

Hi,

Tim Chase wrote:

  Make sure 'ignorecase' is off:
 
  :set noignorecase
 
  :%s/\[a-z]\+\//g
 
 If you don't want to bung with your vim-wide (or bufferwide) 
 settings, you can always just change your :s to include the I flag.
 
   :%s/\[a-z]\+\//gI

another option is to include \C in the regular expression itself:

:%s/\C\[a-z]\+\//g

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)