Re: :s/pattern Undocumented feature?

2006-09-22 Thread Bram Moolenaar

Bill McCarthy wrote:

 On Wed 20-Sep-06 1:08pm -0600, Tim Chase wrote:
 
  I hadn't seen a reply to this fly by, so I thought I'd let you
  know it wasn't entirely ignored :)
 
  It appears that :s/pattern produces the same result as
  :s/pattern//.  I couldn't find that behavior in the docs.
  
  A hidden feature?  (Or was I just not creative enough using
  helpgrep?)
 
  I'm not sure I've seen it anywhere in the docs, but I've noticed
  the same behavior not only in ex/vi/vim, but also in ed.  I was
  originally hesitant to use it, not sure whether it was unintended
  and if it would be there from version to version.  However, after
  finding it consistent from version 5.x of vim forward, in classic
  vi, as well as ed, I presume it's an undocumented feature, and
  have begun using it when I have the need.
 
  I scoured through the help, looking in a multitude of places I
  deemed sensible, and couldn't find anything documented either.
 
 Thanks, Tim, for confirming this feature.
 
 Bram, could you please add a note to the help for ':s' that
 documents this feature?

I thought this was explained somewhere, but I can't find it.  I'll add a
remark below the explanation of an empty pattern.

-- 
Snoring is prohibited unless all bedroom windows are closed and securely
locked.
[real standing law in Massachusetts, United States of America]

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: S

2006-09-22 Thread Yakov Lerner

On 9/22/06, Eric Leenman [EMAIL PROTECTED] wrote:

Hi

I have a file where I deleted all lines that don't contain a certain pattern
For example I want to delete all lines that don't contain XXX and YYY.

Before:

[start of file]
abcde XXX fghij YYY
12345 AAA 67890 BBB
klmno XXX pqrst YYY
09876 XXX 54321 BBB
*()- XXX ,./;' YYY
[end of file]

After:
[start of file]
abcde XXX fghij YYY
*()- XXX ,./;' YYY
[end of file]


:v/XXX.*YYY/d

or

:g!/XXX.*YYY/d

Yakov


Re: :s/pattern Undocumented feature?

2006-09-22 Thread Tim Chase

I scoured through the help, looking in a multitude of places I
deemed sensible, and couldn't find anything documented either.

Thanks, Tim, for confirming this feature.

Bram, could you please add a note to the help for ':s' that
documents this feature?


I thought this was explained somewhere, but I can't find it.  I'll add a
remark below the explanation of an empty pattern.


I'm sure I've seen it in the past as well, but couldn't find it 
either.  Perhaps something directly in the help for :s


 :[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
   For each line in [range] replace a match of
   {pattern} with {string}.
   For the {pattern} see |pattern|.
   {string} can be a literal string, or something
   special; see |sub-replace-special|.

as the help already describes that {string} can be something 
special, it's not a far stretch to also note that


1) with no [flags], the trailing slash can be omitted
2) with no {pattern} and no [flags], both trailing slashes can be 
omitted.


This might also be visually indicated in the definition line 
with something like


 :[range]s[ubstitute]/{pattern}[/{string}[/[flags] [count]]]

to show that the /[flags] portion and the /{string}/[flags] 
portions are optional.


Just a few ideas,

-tim





Re: :s/pattern Undocumented feature?

2006-09-20 Thread Tim Chase
I hadn't seen a reply to this fly by, so I thought I'd let you 
know it wasn't entirely ignored :)



It appears that :s/pattern produces the same result as
:s/pattern//.  I couldn't find that behavior in the docs.

A hidden feature?  (Or was I just not creative enough using
helpgrep?)


I'm not sure I've seen it anywhere in the docs, but I've noticed 
the same behavior not only in ex/vi/vim, but also in ed.  I was 
originally hesitant to use it, not sure whether it was unintended 
and if it would be there from version to version.  However, after 
finding it consistent from version 5.x of vim forward, in classic 
vi, as well as ed, I presume it's an undocumented feature, and 
have begun using it when I have the need.


I scoured through the help, looking in a multitude of places I 
deemed sensible, and couldn't find anything documented either.


-tim






Re: :s/pattern Undocumented feature?

2006-09-20 Thread Bill McCarthy
On Wed 20-Sep-06 1:08pm -0600, Tim Chase wrote:

 I hadn't seen a reply to this fly by, so I thought I'd let you
 know it wasn't entirely ignored :)

 It appears that :s/pattern produces the same result as
 :s/pattern//.  I couldn't find that behavior in the docs.
 
 A hidden feature?  (Or was I just not creative enough using
 helpgrep?)

 I'm not sure I've seen it anywhere in the docs, but I've noticed
 the same behavior not only in ex/vi/vim, but also in ed.  I was
 originally hesitant to use it, not sure whether it was unintended
 and if it would be there from version to version.  However, after
 finding it consistent from version 5.x of vim forward, in classic
 vi, as well as ed, I presume it's an undocumented feature, and
 have begun using it when I have the need.

 I scoured through the help, looking in a multitude of places I
 deemed sensible, and couldn't find anything documented either.

Thanks, Tim, for confirming this feature.

Bram, could you please add a note to the help for ':s' that
documents this feature?

-- 
Best regards,
Bill



Re: :s/pattern Undocumented feature?

2006-09-20 Thread Hari Krishna Dara

On Wed, 20 Sep 2006 at 1:08pm, Tim Chase wrote:

 I hadn't seen a reply to this fly by, so I thought I'd let you
 know it wasn't entirely ignored :)

  It appears that :s/pattern produces the same result as
  :s/pattern//.  I couldn't find that behavior in the docs.
 
  A hidden feature?  (Or was I just not creative enough using
  helpgrep?)

 I'm not sure I've seen it anywhere in the docs, but I've noticed
 the same behavior not only in ex/vi/vim, but also in ed.  I was
 originally hesitant to use it, not sure whether it was unintended
 and if it would be there from version to version.  However, after
 finding it consistent from version 5.x of vim forward, in classic
 vi, as well as ed, I presume it's an undocumented feature, and
 have begun using it when I have the need.

 I scoured through the help, looking in a multitude of places I
 deemed sensible, and couldn't find anything documented either.

 -tim

I found this accidentally too and mostly use it for removing extra
carriage-returns, using :%s/^M (where ^M is a literal Ctrl+M).

-- 
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: s?

2006-07-14 Thread A.J.Mechelynck

Wim R. Crols wrote:

Hi,

Not really a request for help, but I was wondering if you guys ever use 
the 's' command.
It's just a shortcut for 'cl', which I almost never need. Since I don't 
assume it was put in to be complete or something, I'm intrigued by it's 
enigmatic purpose. :)


Thanks,
Wim




There are a number of such aliases whose sole function is to appeal to 
the lazy typist:


:x for :wq
x for dl

(all of this without the quotes of course).

Since I profess that laziness is the mother of invention, and since I'm 
lazy myself in a workaholic kind of way, the existence of such aliases 
(or of the possibility to create shortcuts for almost anything using 
:map, :abbrev and friends) doesn't bother me.



Best regards,
Tony.


Re: s?

2006-07-03 Thread Wim R. Crols
Thanks for all the explanations everyone. I do see your points, and will 
try to add 's' to my weaponry :)


Wim



On 6/30/06, Wim R. Crols [EMAIL PROTECTED] wrote:

Hi,

Not really a request for help, but I was wondering if you guys ever use
the 's' command.
It's just a shortcut for 'cl', which I almost never need. Since I don't
assume it was put in to be complete or something, I'm intrigued by it's
enigmatic purpose. :)

Thanks,
Wim





Re: s?

2006-06-30 Thread Tim Chase
Not really a request for help, but I was wondering if you guys ever use 
the 's' command.
It's just a shortcut for 'cl', which I almost never need. Since I don't 
assume it was put in to be complete or something, I'm intrigued by it's 
enigmatic purpose. :)


I'll admit that it took me a while (several years) to add it to 
my repertoire of actively used vim commands.  I do use it these 
days, as it *does* cut off that extra keystroke.  And, yes, I'm 
that lazy. :)


Most often, I end up using it (s) when I need to alter the end 
of a word, such as removing a terminal ess or removing some 
punctuation and continuing editing from there.  Tangentially, I 
still can't say I use S, as I find cc much easier...both to 
remember and to type.


Just one perspective on the matter...

-tim






Re: s?

2006-06-30 Thread Peter Slizik

 Not really a request for help, but I was wondering if you guys ever use
 the 's' command.
 It's just a shortcut for 'cl', which I almost never need. Since I don't
 assume it was put in to be complete or something, I'm intrigued by it's
 enigmatic purpose. :)

Well, I use it when I want to replace a word that is for example 4 letters 
long.

abcd efgh ijkl

Suppose I want to replace efgh with something else. I place the cursor at 
the beginning of the word and type '4s'. The word disappears and ViM switches 
to the insert mode.

-- Peter


Re: s?

2006-06-30 Thread Michael Naumann
On Friday 30 June 2006 15:16, Wim R. Crols wrote:
 Peter Slizik wrote:
  Not really a request for help, but I was wondering if you guys ever use
  the 's' command.
  It's just a shortcut for 'cl', which I almost never need. Since I don't
  assume it was put in to be complete or something, I'm intrigued by it's
  enigmatic purpose. :)
  
 
  Well, I use it when I want to replace a word that is for example 4 letters 
  long.
 
  abcd efgh ijkl
 
  Suppose I want to replace efgh with something else. I place the cursor at 
  the beginning of the word and type '4s'. The word disappears and ViM 
  switches 
  to the insert mode.
 
  -- Peter

 Yes, I figured out that use, but isn't 'cw' always easier since you 
 don't have to count? And when you need to only replace part, like 
 replacing abcd in abcdef, then I'd rather use 'cfd'.
 Just my 2c of course.
 
 Wim
 
 
cfd may be quite different from 4s in this example, esp. if you intend
to repeat the replacement on other places with ..

- Michael



Re: s?

2006-06-30 Thread Eric Arnold

I can't remember why or when (it was so long ago), but I've always
used 's' and 'S'  in 'vi'.  It never really occured to me to use 'cl'
instead.  It was just another command in the list.

It was part of the original 'vi', but I'm not sure if you meant that
by 'put in to be complete'.

It is no more enigmatic then a lot of things in 'vi' which are there
just to make editing incrementally better.  There's 'C' vs 'c$', 'D',
'G', 'Y', etc., all of which are redundant with combinations of other
commands.


On 6/30/06, Wim R. Crols [EMAIL PROTECTED] wrote:

Hi,

Not really a request for help, but I was wondering if you guys ever use
the 's' command.
It's just a shortcut for 'cl', which I almost never need. Since I don't
assume it was put in to be complete or something, I'm intrigued by it's
enigmatic purpose. :)

Thanks,
Wim