[svlug] Two stupid FAQ questions about VI...

Ivica Steffl steffl at bigfoot.com
Sun Nov 29 23:14:34 PST 1998


Sam Ockman wrote:
> 1) What's the equivalent to esq-q in emacs.  I.e. I've just mananged to
> mangle a paragraph and need some way to reformat it so all the lines end
> at around 70 characters to the right margin.

  you can press !}fmt and enter key, the ! means that the following
command (external program) will be run, the command happens to be fmt in
this case, the text from current cursor position to end of paragraph
(that's what the '}' says, you can use other positioning commands) is
feeded to standard input of the command and whatever the command outputs
on the standard output is put in the place of said text. the command I
gave as an example above formats everything from current cursor position
to the end of paragraph.

  just in case  - the !}fmt is to be pressed in command mode (not in :
mode or insert mode).

  fmt is in slackware distribution, I do not know how standard it is.

> 2) How do I count the number of words in the buffer?

  well, if you've got the patience you can try to focus your eyes on the
first word and say 'one', the shift the focus to second word and say
'two' etc... you get the idea... :-)) ok, so it's not really a practical
way...

  you can also use above ! command - just go to the first line of the
text (1G) then press !wc and hit the enter key and whole text is
replaced by output of wc (wordcount) program, saying how many words and
lines do you have in file, then press 'u' to undo the change (the output
of the wc command will be replaced by the previously present text)

  then there's :[range]w !wc possibility (where range is standard range,
you can use other command instead of wc), text within range will be
feeded to command and standard output of command will be displayed (it
will not overwrite the content of file like the previous way of counting
words). after the output of the command is displayed you are prompted to
press return.

  there might be other ways to do both, as is often the case with unix
systems - you have completely idiotic ways to do things and also very
efficient ways to do achieve the goals.

	erik


--
echo "unsubscribe svlug" | mail majordomo at svlug.org
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to unsubscribe
see http://www.svlug.org/mdstuff/lists.shtml for posting guidelines.



More information about the svlug mailing list