On 03/15/12 01:09, Yasuhiro MATSUMOTO wrote:
[please don't top-post on the vim mailing list; I've reordered]
:%s/\v(Vaya) (con) (Dios)/[\U&](#\L\1-\2-\3)/g

But it only works with that particular text verbatim.  I assumed
the OP wanted something to convert arbitrary lines of text into a
capitalized version of that text, followed by a lowercase version
of the text wherein the spaces were replaced with dashes.  Thus
my initial suggestion of

%s/.*/\='['.toupper(submatch(0)).'](#'.substitute(tolower(submatch(0)),
' ', '-', 'g').')'

But this won't work with "Vaya con Dios: some extra texts...".

Yes, but that then becomes a matter of merely tweaking the regular-expression to match the desired text. So if the OP wanted the entire line to match, they could use ".*"; if they wanted the literal "Vaya con Dios", they could use that literal; if they wanted up to the first punctuation-mark, they could use "^[^[:punct:]]*". The replacement expression does the right thing in each case without needing to change it.

-tim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to