At Fri, 11 Oct 2002 21:22:28 +1000, Bill Bennett wrote:
> I use vi as an editing language.
> I'd like a command that would put in the section command and
> capitalize the leading letters of all words in a line that
> are *not* of one, two or three letters. However, the first
> word in the line, regardless of the number of letters *must*
> have a leading capital.
i don't want to start an argument or anything, i just don't think
you're using the right tool for the job.
eg: here is a fairly straightforward (imo) piece of elisp that will do
exactly what you want:
(defun bozotitlecase-section-ify ()
"replace \"and this is the current line\" with
\"\\section{And This is the Current Line}\""
(interactive)
(beginning-of-line)
;; match the beginning of any word of 4 or more characters, or the
;; first on the line
(while (re-search-forward "^\\w\\|\\<\\w\\{4\\}" (point-at-eol) t)
;; upcase the first letter of whatever we just matched
(replace-match "\\u\\&"))
(beginning-of-line)
(insert-string "\\section{")
(end-of-line)
(insert-string "}"))
and if writing elisp is too difficult, you could have recorded a macro
that would have generated pretty much the same code.
if they were the only "freestanding" single lines in your text (ie:
they could be found without user interaction), you might also want to
consider preprocessing your document with a simple perl (or similar)
script. even if the script got it wrong 10% of the time, you're
already way ahead.
--
- Gus
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug