Loading ...
Sorry, an error occurred while loading the content.

Re: changing case of html tags

Expand Messages
  • Benji Fisher
    ... According to http://www.vim.org/mail.html#archives the archive for this list is http://www.yahoogroups.com/list/vim . I think that ...
    Message 1 of 3 , May 2 10:43 AM
    • 0 Attachment
      Nicole Lallande wrote:
      >
      > Greetings,
      >
      > How do I change the case of all html tags in a file from uppercase to
      > lowercase? BTW, is there an archive for this list - I hate to think I
      > am asking a question that has been asked a zillion times before. (My
      > apologies if this is one of those questions.)

      According to http://www.vim.org/mail.html#archives the archive for
      this list is http://www.yahoogroups.com/list/vim .

      I think that

      :%s/<[^>]*>/\L&/g

      will do what you want. Explanation:

      :% Apply what follows to each line in the file
      s/pattern/replace/flags Substitute pattern with replace; the "g" flag
      means everywhere in the line, not just the
      first occurrence.
      /<[^>]*>/ matches a "<" followed by any number of non-">" character,
      followed by a ">"
      /\L&/ & refers to the whole match and \L means convert it to lower case

      This will not handle all cases. For example, it will miss HTML tags that
      span more than one line. When it does work, it will make everything
      between "<" and ">" lower case, including 'href="CaseSensitiveFileName"'.
      It might be safer to use /<[^ \t>]*/ for the pattern: a "<" character,
      followed by as many non-space, non-tab, non-">" characters as possible.

      HTH --Benji Fisher
    Your message has been successfully submitted and would be delivered to recipients shortly.