hello,

> > so you can write:
> >
> >     :w|grep -c abc %
> That doesn't really fit the bill:
> 1. This error message is produced: 'The grep command is unknown'

because i wasted it by missing the bang

     :w|!grep -c abc %

is a single line way to write

     :w
     :!grep -c abc %

> 2. grep only counts the number of lines.  If the 'abc' reappears in
> the same line, grep won't catch that.  My version will, however
> crufty, though it's arguably better/shorter/more portable to use your
> %:

true. is this fine enough ?

    :w !tr -cs '[:alnum:]' '\n'|grep -c abc

> >     :w !grep -c
> 
> That produces a grep usage prompt here, along with this message:
> 'grep -c: exited with status 2.'

... was an example: you can add your pattern there

     :w !grep -c abc

> Are you sure you've tested this and that you're using just plain (n)vi?

nvi debian and vi from openbsd 6.9

> Wow, that's... helpful(?), I think, but truth be told

oh yes it is :)

> I've tested
> none of this, because I'm slightly overwhelmed by what to me looks
> like far greater complexity than :E, ^W etc. -- and even than my
> occurrence-counting one-liner.

Fair enough. so check the quick ref about windows (:h Q_wi) especially
the ones that makes you feel the nvi way.

CTRL-W s  or  :split    split window into two parts
:split {file}           split window and edit {file} in one of them
CTRL-W ]                split window and jump to tag under cursor
CTRL-W f                split window and edit file name under the cursor
CTRL-W ^                split window and edit alternate file
CTRL-W j                move cursor to window below
CTRL-W k                move cursor to window above
CTRL-W CTRL-W           move cursor to window below (wrap)
CTRL-W W                move cursor to window above (wrap)
CTRL-W t                move cursor to top window
CTRL-W b                move cursor to bottom window
CTRL-W p                move cursor to previous active window

> Maybe I'm just not truly ready for vim (though I do use it at times).

there is no such thing as 'ready for vim'. nowadays, i still find stuff
on the vim help and think 'damn! i missed it since 25 years!' vi (and
vim) is a langage the way english is: lot of experience and vocabulary
helps you to be much more concise and precise but you don't need PhD
to have helpful cheap chats.

> None of the above is intended as throwing anything back in your face
> however, and I thank you very much for your reply.

I really don't took things personally and i know that vim is an
overbloated vi but some features are really awesome and the UI is
simpler to use (i don't care about the look but vim is more forgiven
and comes with helpful visual signals). On the other hand: nvi is a too
minimal subset of it to be my daily editor but it's really helpful for
simple sysop tasks.

>From time to time, someone starts a new clone to try to reach a new
balance but vim and nvi pleases enough people so those projects are doomed.

regards,
marc

Reply via email to